.net - C# InvalidOperationException AND Cross-thread operation -


In the form of my windows I have a text box and a button, text box "tb_logbox" is a multilingual text box. To create a background worker that calls the function "i.e. logtime timer." When I compile and run it, Visual Studio throws a non-functional operation exposition.

Actual error I'm not getting cross-thread operation valid: Control reached 'tb_logbox' from thread another thread that it was created. The following sample code indicates what I am trying to do.

  Private Zero Button 1_Click {Object Sender, EventArgs E} {try {var bw = new BackgroundWorker ()} Bw.DoWork + = ExecuteOperations; Bw.RunWorkerAsync (); } Hold (exception before) {tb_LogBox.AppendText (environment. NewLine + "= @ =" + east. "" + "Pre source); }} Private Zero ExecuteOperations (Object Sender, DoWorkEventArgs e) {var FuncCall = New LogTimer (); Tb_LogBox.AppendText (EnvironmentalNew + FuncCall.DnT ()); // line is getting error on me} Public class LogTimer {public string (DNT) {constant string datePat = @ "d / MM / yyyy"; Var dateTime = DateTime.Now (); Return Date Time Toastring (datapat); }}  

Try using the method of getting started:

  BeginInvoke (new action ((=) gt; {tb_LogBox.AppendText (environment. NewLine + FuncCall.DnT ());}));  

It will be sleek by invocals.


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -