Question about background workers

This is a discussion on Question about background workers within the C# Programming forums, part of the General Programming Boards category; I have a breadth first search that I've been toying with for a bit, and it works very well. The ...

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    13

    Question about background workers

    I have a breadth first search that I've been toying with for a bit, and it works very well. The problem is, that if it has to perform more than a certain number of comparisons it freezes my computer. I tried adding a backgroundWorker but it never completes the function. It enters, according to the various break points I've added but never completes it. Is there a certain amount of code that a background worker will do or is there more that I need to add then the following:

    Code:
    form1()
    {
                  //various setups for the search 
    
                    backgroundWorker1.DoWork += new          doWorkEventHandler(backgroundWorker1_DoWork);
                    backgroundWorker1.RunWorkerAsync();
    }
    
    private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
    {
                   breadthFirst();
    }

    all the variables are global so it shouldn't be a problem with variable passing. Any help would be very appreciated.

  2. #2
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Perhaps the problem lies in you are calling the function you are calling, not the threads which you are creating. May we look at the function that is causing the hang, por favor.

  3. #3
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    There is a ProgressChanged event that's triggered when you call "ReportProgress(int progress, obj result)" within the DoWork event and can constantly update the status of the calculation. You can then set flags and cancel it with CancelAsync method.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. another do while question
    By kbpsu in forum C++ Programming
    Replies: 3
    Last Post: 03-23-2009, 01:14 PM
  2. Windows background color
    By Exile in forum Windows Programming
    Replies: 2
    Last Post: 01-23-2005, 07:55 AM
  3. Detect Close of a background process
    By Schwarzhelm in forum C Programming
    Replies: 1
    Last Post: 11-05-2003, 01:46 AM
  4. Allegro Question..
    By o0obruceleeo0o in forum Game Programming
    Replies: 3
    Last Post: 07-01-2003, 02:10 PM
  5. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 09:22 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21