Re: BackgroundWorker not working...

From: Daniel Moth (dmoth74_at_hotmail.com)
Date: 01/11/05


Date: Tue, 11 Jan 2005 18:45:34 -0000

Carsten, you will have to always provide details on the errors you are
seeing. Simply asking "what is wrong" does not give any information. In the
code you posted, you left out the most important method: thisRefreshView

Now, the blog entry you downloaded the BW from, had links that describe each
method. Please read them. In particular from my blog post read this part:
 4a. It raises the event. In your DoWorkEventHandler method do your
background stuff (without touching GUI of course)

The key being "without touching the GUI of course". So, in your mBW_DoWork
method do not touch UI elements (you can do that from any other method you
like).

Feel free to post back with specifics.

Cheers
Daniel

--
http://www.danielmoth.com/Blog/
"Carsten Marx" <Carsten.Marx@uni-konstanz.de> wrote in message 
news:uoYN4xA%23EHA.3988@TK2MSFTNGP11.phx.gbl...
> ok, my fault....
> now here my code:
>
> // Call this method in form's ctor
> private void InitBW()
> {
> mBW = new BackgroundWorker(this);
> mBW.RunWorkerCompleted += new 
> RunWorkerCompletedEventHandler(mBW_RunWorkerCompleted);
> mBW.ProgressChanged += new 
> ProgressChangedEventHandler(mBW_ProgressChanged);
> mBW.DoWork += new DoWorkEventHandler(mBW_DoWork);
> mBW.WorkerReportsProgress = true;
> mBW.WorkerSupportsCancellation = true;
> }
>
> // Completion event
> private void mBW_RunWorkerCompleted(object sender, 
> RunWorkerCompletedEventArgs e)
> {
> this.pgBar.Hide();
>
> }
>
> // Progress event
> private void mBW_ProgressChanged(object sender, ProgressChangedEventArgs 
> e)
> {
> this.pgBar.BringToFront();
> this.pgBar.Value = e.ProgressPercentage;
> }
>
> // On worker thread! Only method with real logic
> private void mBW_DoWork(object sender, DoWorkEventArgs e)
> {
> this.refreshView();
> }
>
> /// <summary>
> /// manage the click on the TYP button
> /// </summary>
> /// <param name="sender"></param>
> /// <param name="e"></param>
> private void bTYP_Click(object sender, EventArgs e)
> {
> this.activeCategory = "TYP";
> this.resetActiveCategory();
> this.BackColor = Preferences.COLOR_CATEGORY_TYP;
> this.refreshView();
>
> }
>
> the method refreshView handles some stuff to load data and managa the 
> gui...
> whats wrong?
>
>
> Daniel Moth wrote:
>> In .NET projects (desktop of CF) adding a reference to a class library is 
>> the first step for using the code in the dll.
>>
>> The second step is to show your intent in the code file that you will be 
>> using types from the namespace(s) in the said dll.
>>
>> In this case this means the ComponentModel namespace.
>>
>> Try inserting the following line at the top of your file:
>> using System.ComponentModel;
>>  or in VB:
>> Imports System.ComponentModel
>>
>> Let me know if you are still having problems and I do recommend 
>> downloading the sample I pointed out (you would have found this on your 
>> own then :-)
>>
>> Cheers
>> Daniel
>> --
>> http://www.danielmoth.com/Blog/
>>
>>
>> "Carsten Marx" <Carsten.Marx@uni-konstanz.de> wrote in message 
>> news:%23GoRl9$9EHA.2196@TK2MSFTNGP14.phx.gbl...
>>
>>>Daniel Moth wrote:
>>>
>>>>Can you share the client code and describe what "does not working" mean?
>>>>
>>>>There is a sample here:
>>>>http://www.danielmoth.com/Blog/2004/12/backgroundworker-sample.html
>>>>
>>>>Cheers
>>>>Daniel
>>>>--
>>>>http://www.danielmoth.com/Blog/
>>>>
>>>>
>>>>"Carsten Marx" <Carsten.Marx@uni-konstanz.de> wrote in message 
>>>>news:%23UN5f2$9EHA.2540@TK2MSFTNGP09.phx.gbl...
>>>>
>>>>
>>>>>Hello,
>>>>>i tried to create an instance of the BackgroundWorker
>>>>>http://www.danielmoth.com/Blog/2004/12/backgroundworker-for-cf-10.html
>>>>>after adding the dll to my Projekt.
>>>>>But it's not working... Whats wrong?
>>>>>
>>>>>regards
>>>>>carsten
>>>>
>>>>
>>>>
>>>[ Der Typ oder Namespace 'BackgroundWorker' konnte nicht gefunden werden. 
>>>Möglicherweise fehlt eine Anweisung oder ein Assemblyverweis.]
>>>..sorry german..
>>>In English it should be:
>>>The type or namespace "BackgroundWorker" could not be found....
>>>
>>>
>>>regards carsten
>>>
>>>btw: the dll is added to the project...
>>
>>