考虑这个 WinForms 程序:
Module Main
Dim notifyicon As New System.Windows.Forms.NotifyIcon
'Dim dummycontrol As New System.Windows.Forms.Control
Public Sub Main()
If (System.Threading.SynchronizationContext.Current Is Nothing) Then
MessageBox.Show("Nothing")
Else
MessageBox.Show("Something")
End If
End Sub
End Module
NotifyIcon 是一个 WinForm 控件,并且需要一个消息循环,那么为什么声明dummycontrol
(或任何 WinForms 控件)会设置一个 SynchronizationContext,而 NotifyIcon 没有呢?