Click here to Skip to main content
15,913,941 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to Run executable by a windows service Pin
Vikram A Punathambekar18-Sep-08 22:53
Vikram A Punathambekar18-Sep-08 22:53 
GeneralRe: How to Run executable by a windows service Pin
Giorgi Dalakishvili18-Sep-08 22:59
mentorGiorgi Dalakishvili18-Sep-08 22:59 
GeneralRe: How to Run executable by a windows service Pin
Vikram A Punathambekar19-Sep-08 6:21
Vikram A Punathambekar19-Sep-08 6:21 
AnswerRe: How to Run executable by a windows service Pin
#realJSOP18-Sep-08 23:49
professional#realJSOP18-Sep-08 23:49 
QuestionSet timeout to asynchron calls Pin
greekius18-Sep-08 20:37
greekius18-Sep-08 20:37 
QuestionConnect to camera with C# Pin
Member 467828718-Sep-08 20:26
Member 467828718-Sep-08 20:26 
QuestionRe: Connect to camera with C# Pin
Mark Salsbery19-Sep-08 7:07
Mark Salsbery19-Sep-08 7:07 
QuestionBackgroundWorker method executing twice Pin
scody18-Sep-08 18:20
scody18-Sep-08 18:20 
Below is the skeleton code which demonstrates the way I have used the BackgroundWorker class. I followed the example provided in MSDN. For some reason MyTimeConsumingTask executes twice before the bgWorker_RunWorkerCompleted handles it.

Any help would be greatly appriciated.

//Form Class
void bgWorker_DoWork(object sender, DoWorkEventArgs e)
{
    // Get the BackgroundWorker that raised this event.
    BackgroundWorker worker = sender as BackgroundWorker;

    e.Result = MyTimeConsumingTask(e.Argument, worker, e);

}

void bgWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
    // First, handle the case where an exception was thrown.
    if (e.Error != null)
    {
        MessageBox.Show(e.Error.Message);
    }
    else if ((bool)e.Result)
    {
        //MyTimeConsumingTask successfully executed
    }
    else
    {
        //MyTimeConsumingTask failed
    }
}
//Form Class end


//Another Class
internal bool MyTimeConsumingTask(object arg, BackgroundWorker worker, DoWorkEventArgs e)
{
    //Actual task is performed here, for simplicity sleep has been used.
    Thread.Sleep(10000);
    return true;
}
//Another Class end

AnswerRe: BackgroundWorker method executing twice Pin
N a v a n e e t h18-Sep-08 19:30
N a v a n e e t h18-Sep-08 19:30 
GeneralRe: BackgroundWorker method executing twice Pin
scody18-Sep-08 20:35
scody18-Sep-08 20:35 
GeneralRe: BackgroundWorker method executing twice Pin
#realJSOP18-Sep-08 23:53
professional#realJSOP18-Sep-08 23:53 
AnswerRe: BackgroundWorker method executing twice Pin
Steve Echols18-Sep-08 19:51
Steve Echols18-Sep-08 19:51 
AnswerRe: BackgroundWorker method executing twice Pin
scody18-Sep-08 21:03
scody18-Sep-08 21:03 
QuestionHow do I know BackgroundWorker work complete? Pin
mimimimilaw18-Sep-08 18:01
mimimimilaw18-Sep-08 18:01 
AnswerRe: How do I know BackgroundWorker work complete? Pin
N a v a n e e t h18-Sep-08 18:12
N a v a n e e t h18-Sep-08 18:12 
GeneralRe: How do I know BackgroundWorker work complete? Pin
mimimimilaw18-Sep-08 18:56
mimimimilaw18-Sep-08 18:56 
GeneralRe: How do I know BackgroundWorker work complete? Pin
N a v a n e e t h18-Sep-08 19:28
N a v a n e e t h18-Sep-08 19:28 
AnswerRe: How do I know BackgroundWorker work complete? Pin
#realJSOP18-Sep-08 23:57
professional#realJSOP18-Sep-08 23:57 
QuestionHow to compress and decompress an image using GDI+ JPEG? Pin
gigahertz20518-Sep-08 17:57
gigahertz20518-Sep-08 17:57 
AnswerRe: How to compress and decompress an image using GDI+ JPEG? Pin
Anthony Mushrow19-Sep-08 1:02
professionalAnthony Mushrow19-Sep-08 1:02 
QuestionOutlook Issue. Newbie Question Pin
kruegersck18-Sep-08 17:33
kruegersck18-Sep-08 17:33 
QuestionFIB Pin
Miss_hacker18-Sep-08 16:09
Miss_hacker18-Sep-08 16:09 
QuestionCan i write a small plugin for Internet Explorer in .Net ? Pin
SWSDEV18-Sep-08 14:28
SWSDEV18-Sep-08 14:28 
QuestionCrystal Reports Help Pin
Alldaypilot18-Sep-08 14:10
Alldaypilot18-Sep-08 14:10 
QuestionRead already opened file Pin
srabik18-Sep-08 13:27
srabik18-Sep-08 13:27 

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.