BackgroundWorker
を更新すると思われる を実行していますUserControl
。プロパティを確認した後、呼び出しを試みましたInvokeRequired
:
private void bgwHighlightText_DoWork(object sender, DoWorkEventArgs e)
{
tmpRich.SelectedRtf = myRtf;
if (_ucResultRich.InvokeRequired && _ucResultRich.rchResult.InvokeRequired)
_ucResultRich.Invoke(new Action(() => _ucResultRich.rchResult.Rtf = tmpRich.Rtf)); // Debug pointer stops here
//Rest of the code
}
RichTextBox
また、内部をUserControl
直接呼び出そうとしました:
_ucResultRich.rchResult.Invoke(new Action(() => _ucResultRich.rchResult.Rtf = tmpRich.Rtf));
しかし、コードをデバッグすると、残りのコードの実行がエラーなしで停止するだけです。
_ucResultRich.InvokeRequired
と_ucResultRich.rchResult.InvokeRequired
returnの両方true
。
ここで何か間違ったことをしていますか?
アップデート
Invoke
パーツを挿入するtry catch
と、例外メッセージから次のエラーが表示されます。
Cross-thread operation not valid: Control '' accessed from a thread
other than the thread it was created on.
コントロールを決定できないからですか?のように表示されControl ''
ます。