-2
此代碼是從其創建的線程之外的其他線程運行的。
線程得到從StartScanning
WinForms線程調用處理
public StartScanning()
{
InitializeComponent();
Thread _IMSS_THREAD = new Thread(_IMSS_START_SCANNING);
_IMSS_THREAD.IsBackground = true;
_IMSS_THREAD.Start();
}
主要形式
StartScanning _IMSS_START_SCANNING = StartScanning._IMSS_CREATE_CONTROLE();
_IMSS_START_SCANNING._IMSS_ON_ALL_SCAN_COMPLETE += _IMSS_ON_SCAN_COMPLETE;
this._IMSS_MainPanel.Controls.Add(_IMSS_START_SCANNING);
在掃描完整的用戶控制的構造函數創建,這個代碼是主要形式有:
ScanComplete _IMSS_ON_COMPLETE = new ScanComplete();
public void _IMSS_ON_SCAN_COMPLETE(ref List<BetterListViewGroup> _IMSS_LIST_OF_GROUP_TARGETS)
{
List<BetterListViewGroup> IMSS_LIST_OF_GROUP_TARGETS = _IMSS_LIST_OF_GROUP_TARGETS;
_IMSS_ON_COMPLETE._IMSS_AddRangeTargets(ref IMSS_LIST_OF_GROUP_TARGETS);
this.Invoke(new MethodInvoker(() =>
{
this._IMSS_MainPanel.Controls.Clear();
this._IMSS_MainPanel.Controls.Add(_IMSS_ON_COMPLETE);
}));
}
如果坐看看這段代碼,它運行正常,但它應該拋出 跨線程操作無效,因爲當我們sta RT這個用戶控件
ScanComplete _IMSS_ON_COMPLETE = new ScanComplete();
讓主線程創建的程序(這是全球性),並且當我們使用
_IMSS_ON_COMPLETE._IMSS_AddRangeTargets(ref IMSS_LIST_OF_GROUP_TARGETS);
它增加的listview
組給它的列表,它的出調用的節,但它不是拋出線程錯誤,爲什麼它不會拋出錯誤?
和最相關:WinForms,WPF,其他? –
Windows窗體應用程序 –
你在哪裏創建這些線程?我沒有看到任何 –