BackgroundWorker not working...

C

Carsten Marx

Daniel said:
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
[ 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...
 
A

Alex Feinman [MVP]

Forgot "using" (or "Imports")?

--
Alex Feinman
---
Visit http://www.opennetcf.org
Carsten Marx said:
Daniel said:
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
[ 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...
 
D

Daniel Moth

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 said:
Daniel said:
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
[ 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...
 
C

Carsten Marx

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 said:
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/


Daniel said:
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/




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...
 
D

Daniel Moth

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 said:
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 said:
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/


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/




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...
 
G

Guest

Shouldn't touch the UI from anything mBW_DoWork calls either since it's
still the same worker thread context. He *must* use Invoke to touch the UI,
and I'd bet dollars to donuts that's the probelm.

-Chris

Daniel Moth said:
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 said:
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 said:
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/



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/




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...
 
D

Daniel Moth

Shouldn't touch the UI from anything mBW_DoWork calls either since it's
still the same worker thread context.
That is what I mean by "in your mBW_DoWork method do not touch UI elements"
Whether your phraseology gets the point across or mine it's all good at the
end of the day
He *must* use Invoke to touch the UI, and I'd bet dollars to donuts that's
the problem.
He doesn't need to use Invoke; that is one of the advantages of the
BackgroundWorker. Anytime he wants to touch the GUI he calls
mBW.ReportProgress from within the mBW_DoWork method. (it took me a while to
get used not being in control of it but believe me this component is
beautiful :))

Cheers
Daniel
--
http://www.danielmoth.com/Blog/


Shouldn't touch the UI from anything mBW_DoWork calls either since it's
still the same worker thread context. He *must* use Invoke to touch the
UI, and I'd bet dollars to donuts that's the probelm.

-Chris

Daniel Moth said:
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 said:
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/



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/




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...
 
G

Guest

That is what I mean by "in your mBW_DoWork method do not touch UI
elements"
Whether your phraseology gets the point across or mine it's all good at
the end of the day

Yep, I know that's what you meant, but I've found that being very explicit
about things like that helps prevent follow on questions.
He doesn't need to use Invoke; that is one of the advantages of the
BackgroundWorker. Anytime he wants to touch the GUI he calls
mBW.ReportProgress from within the mBW_DoWork method. (it took me a while
to get used not being in control of it but believe me this component is
beautiful :))

That's pretty cool. I'll have to make note to use the class in the future.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top