HostBindings

https://www.thecodecampus.de/blog/angular-2-use-hostbindings-set-class/
And I played a little bit with it in the sandbox,  it seems it can not only bind to class (class itself is just an attr) but also can bind a boolean value to a specific class as a switch.  And it can bind to any customized attribute.
https://stackblitz.com/edit/angular-playground-325-fn6rkg?file=app%2Fbox%2Fbox.component.ts

in case forget about the syntax of using ampersand (&) in pseudo-class :host in sass/scss
here is the reference:
https://css-tricks.com/the-sass-ampersand/

转载:executioncontext-vs-synchronizationcontext

http://blogs.msdn.com/b/pfxteam/archive/2012/06/15/executioncontext-vs-synchronizationcontext.aspx?Redirected=true

果然如其所说,System.Threading.ExecutionContext有两个Run方法。
调用await关键字实际上就是用ThreadpoolTaskScheduler, 内部的方法实际都是用ignoreSyncContext那个参数的Run
// System.Threading._ThreadPoolWaitCallback
[SecurityCritical]
internal static void PerformWaitCallbackInternal(_ThreadPoolWaitCallback tpWaitCallBack)
{
if (tpWaitCallBack._executionContext == null)
{
WaitCallback waitCallback = tpWaitCallBack._waitCallback;
waitCallback(tpWaitCallBack._state);
return;
}
ExecutionContext.Run(tpWaitCallBack._executionContext, _ThreadPoolWaitCallback._ccb, tpWaitCallBack, true);
}
除了这个,另一个用了ExecutionContext却没有传递SynchronizationContext的例子见这里。即DispatcherOperation的Invoke也存在对SyncCtx的特殊对待。

Dispatcher的运行机制

归根到底,也还是Windows API,即:

1.通过注册Window Message
2.给当前Window(Win32里的Window)添加Window Procedure来处理注册过的Windows Message,
3. DispatcherFrame的Push方法里则是传统的Translate和DispatchMessage的过程。直到这个Frame不再Continue.
4. 默认的Frame是由Application的RunDispatcher启动起来的,Application是DispatcherObject的子类,带有一个Dispatcher。
5. 由4上溯Application.Run则可以一直上溯到static Main()方法,程序的入口。
一些关键代码:
1. Static Dispatcher() //WindowMessage是整个操作系统级别的,会被所有WPF程序共享
 Dispatcher._msgProcessQueue = UnsafeNativeMethods.RegisterWindowMessage(“DispatcherProcessQueue”);
2. Dispatcher() ctor :
 this._hook = new HwndWrapperHook(this.WndProcHook);

this._window.Value.AddHook(this._hook);

—->

private IntPtr WndProcHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled):
     if (msg == (int)Dispatcher._msgProcessQueue)
{
this.ProcessQueue();
}
—->
ProcessQueue():
 dispatcherOperation.Invoke(); //自带ExecutionContext,顺便说一下,如果是别的线程里BeginInvoke,会ExecutionContext.Capture(),包括synchornizationContext,securityContext在内都抓下来。但是,Invoke机制对SynchronizationContext有特殊处理,这样ExecutionContext.Run()里的SetExecutionContext方法白白flow了SynchronizationContext
// System.Windows.Threading.DispatcherOperation
[SecurityCritical]
private void InvokeImpl()
{
SynchronizationContext current = SynchronizationContext.Current;
bool flag = current != this._dispatcher._dispatcherSynchronizationContext;
try
{
if (flag)
{
SynchronizationContext.SetSynchronizationContext(this._dispatcher._dispatcherSynchronizationContext);
}
this._result = this._dispatcher.WrappedInvoke(this._method, this._args, this._numArgs);
}
3.Dispatcher.PushFrameImpl()
     while (frame.Continue && this.GetMessage(ref mSG, IntPtr.Zero, 0, 0))
{
this.TranslateAndDispatchMessage(ref mSG); //Translate和DispatchMessage的方法就是native的同名方法
}