Is it possible to call a method inside a BackgroundWorker's Do_Work event?


hi,

i'm trying call long data processing method inside a do_work event. it's skipping it.  example:

private void backgroundworker1_dowork(object sender, doworkeventargs e)
{
    clipshapefile();
}

appeciate help.


marilyn gambone

sure is. if method code controls of form, have invoke (because control created ui thread, cannot access other thread).

can do:

void dowork(...) {     clipshapefile(); }  void clipshapefile() {     if(yourcontrol.invokerequired)         yourcontrol.invoke((action)(() => clipshapefile()));     else     {         //access controls     } }

otrherwise, if there no code inside your clipshapefile() access controls created on ui thread, not need code. thats it.

hope helps.


mitja



Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'