none
backgroundworker issue RRS feed

  • Question

  • 0
    answers
       
    0 votes
    1
    view
    Tags: C#, Mobile

    hey all
    i have issue with backgroundworker :
    1-i am working on mobile application and the CF dnt support backgroundworker
    2- i got the dll. for Backgroundworker from this site http://www.danielmoth.com/Blog/backgroundworker-for-cf-10.aspx
    3- i tried this code
    BackgroundWorker bw;
    bw = new BackgroundWorker();
    bw.DoWork += new DoWorkEventHandler(bw_DoWork);
    bw.RunWorkerAsync();
    void bw_Dowork ()
    {
    int i=0; do
    {
    system.writeline("1");
    }while(i==0);
    }

    this part of code perform the function in bw_Dowork but still not able to run other function with it like if i have button in form i can't able to click on the button because application perform other operation ?
    any idea for this ??!!

    if u have any other method or way to perform function but make application free to control and clicks and perform other function
    Monday, June 28, 2010 1:27 PM

Answers

  • That is a very unfriendly loop, it runs forever and uses 100% of the CPU cycles that aren't being used by higher priority threads.  Very bad form.

    Try blocking with a call to some sleep function.   This isn't a managed code forum, so don't expect to get an exact answer.


    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.
    www.Eurotech.com
    Monday, June 28, 2010 2:30 PM
    Moderator

All replies

  • That is a very unfriendly loop, it runs forever and uses 100% of the CPU cycles that aren't being used by higher priority threads.  Very bad form.

    Try blocking with a call to some sleep function.   This isn't a managed code forum, so don't expect to get an exact answer.


    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.
    www.Eurotech.com
    Monday, June 28, 2010 2:30 PM
    Moderator
  • thx for ur answer yes i tried sleep and it  worked fine

    am not use the loop like this but it is for example only :)

    Wednesday, June 30, 2010 4:01 PM