Click here to Skip to main content
15,886,919 members
Home / Discussions / C#
   

C#

 
QuestionRe: Backgroundworker Thread Issue Pin
munishk20-Jul-12 6:50
munishk20-Jul-12 6:50 
AnswerRe: Backgroundworker Thread Issue Pin
Ian Shlasko20-Jul-12 7:39
Ian Shlasko20-Jul-12 7:39 
AnswerMessage Closed PinPopular
20-Jul-12 7:56
WebMaster20-Jul-12 7:56 
GeneralRe: Backgroundworker Thread Issue Pin
munishk21-Jul-12 3:50
munishk21-Jul-12 3:50 
AnswerRe: Backgroundworker Thread Issue Pin
DaveyM6920-Jul-12 7:56
professionalDaveyM6920-Jul-12 7:56 
AnswerRe: Backgroundworker Thread Issue Pin
Sunil P V20-Jul-12 20:33
Sunil P V20-Jul-12 20:33 
GeneralRe: Backgroundworker Thread Issue Pin
munishk21-Jul-12 3:50
munishk21-Jul-12 3:50 
GeneralRe: Backgroundworker Thread Issue Pin
Sunil P V21-Jul-12 18:51
Sunil P V21-Jul-12 18:51 
Hey munishk,
I had developed and application that created approximate of 20 Background workers. All these workers had to update progressbars embedded in a listview for around 20 listview items. However, initially the DoWork event handler used to update the UI which made the UI very sloppy and was sometimes showing a hung behavior. I changed the implementation to make use of Delegates to update the UI and by calling the BeginInvoke method this issue got resolved.

C#
// declare a delegate to update your progress
void delegate UpdateProgressDelegate(object params);

private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
      //Do Intensive Work
      ArgumentClass backGroundCls = e.Argument as ArgumentClass;
 
      //Now you can do whatever you want to do with passed arguments

      int ctr=0;
      do
      {
          ctr++;
          UpdateProgressDelegate del = new UpdateProgressDelegate(UpdateProgress);
          del.BeginInvoke(ctr, null, null);
      } while (ctr < 10000000);
}

private void UpdateProgress(int ctr)
{
    // update progress here
}


This should definitely work and solve your issue.
Sunil

QuestionProblem with Math.Tan Function Pin
computerpublic20-Jul-12 6:12
computerpublic20-Jul-12 6:12 
AnswerRe: Problem with Math.Tan Function Pin
BobJanova20-Jul-12 6:20
BobJanova20-Jul-12 6:20 
GeneralRe: Problem with Math.Tan Function Pin
computerpublic20-Jul-12 6:22
computerpublic20-Jul-12 6:22 
GeneralRe: Problem with Math.Tan Function Pin
computerpublic20-Jul-12 6:30
computerpublic20-Jul-12 6:30 
GeneralRe: Problem with Math.Tan Function Pin
BobJanova22-Jul-12 22:56
BobJanova22-Jul-12 22:56 
GeneralRe: Problem with Math.Tan Function Pin
lewax0020-Jul-12 7:11
lewax0020-Jul-12 7:11 
GeneralRe: Problem with Math.Tan Function Pin
computerpublic20-Jul-12 7:33
computerpublic20-Jul-12 7:33 
GeneralRe: Problem with Math.Tan Function Pin
lewax0020-Jul-12 7:57
lewax0020-Jul-12 7:57 
GeneralRe: Problem with Math.Tan Function Pin
djdanlib20-Jul-12 10:48
djdanlib20-Jul-12 10:48 
GeneralRe: Problem with Math.Tan Function Pin
Dave Kreskowiak20-Jul-12 13:17
mveDave Kreskowiak20-Jul-12 13:17 
GeneralMessage Closed Pin
20-Jul-12 6:28
WebMaster20-Jul-12 6:28 
GeneralRe: Problem with Math.Tan Function Pin
lewax0020-Jul-12 6:55
lewax0020-Jul-12 6:55 
AnswerRe: Problem with Math.Tan Function Pin
SledgeHammer0120-Jul-12 8:16
SledgeHammer0120-Jul-12 8:16 
QuestionReturning Huge XML data from procedure Pin
AB777120-Jul-12 0:03
AB777120-Jul-12 0:03 
AnswerRe: Returning Huge XML data from procedure Pin
Bernhard Hiller20-Jul-12 1:07
Bernhard Hiller20-Jul-12 1:07 
GeneralRe: Returning Huge XML data from procedure Pin
AB777120-Jul-12 4:19
AB777120-Jul-12 4:19 
GeneralRe: Returning Huge XML data from procedure Pin
jschell20-Jul-12 7:38
jschell20-Jul-12 7:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.