which event has been raised  
Author Message
invoke





PostPosted: Visual C# Language, which event has been raised Top

how can i know from inside a DoWork event handler " backgroundworker" that a specific button has been pressed
dowork
{
if btn1_clicked execute procedure1
if btn2_clicked execute procedure2

}




Visual C#17  
 
 
Peter Ritchie





PostPosted: Visual C# Language, which event has been raised Top

Usually the click of a button either cancels an executing BackgroundWorker process or starts a new one. Are you expecting to start a BackgroundWorker to sit and wait for button presses

 
 
invoke





PostPosted: Visual C# Language, which event has been raised Top

if i press one of the button , a backgroundworker should be start , but instead of using two backgroundworkers , i was tried to use a one and inside a DoWork event i will put the if statement to choose which procedure to start depending on the type of the button clicked

 
 
Peter Ritchie





PostPosted: Visual C# Language, which event has been raised Top

What if the first process isn't complete when the second button is pressed I would just use two background worker objects or two DoWork handlers...

 
 
Kuhndog





PostPosted: Visual C# Language, which event has been raised Top

You could pass the EventArg to the dowork function then test what command was pressed.

dowork(EventArgs e)

{

if(e.command.commandname == "btn1"){execute procedure1}

if(e.command.commandname == "btn2"){execute procedure2}

}



 
 
Peter Ritchie





PostPosted: Visual C# Language, which event has been raised Top

You could pass the EventArg to the dowork function then test what command was pressed.

dowork(EventArgs e)

{

if(e.command.commandname == "btn1"){execute procedure1}

if(e.command.commandname == "btn2"){execute procedure2}

}

You'd have to re-call the RunWorkerAsync method in order to get a different EventArg to the DoWork event; might as well create a new event handler or new BackgroundWorker...

 
 
Baris ERGUN





PostPosted: Visual C# Language, which event has been raised Top

Can you tell more specifically your application. This sounds like a Threading application to me and I can help you with that as I have done many. Just spend some time ;)

 
 
invoke





PostPosted: Visual C# Language, which event has been raised Top

it's a monitoring and management for network elements(cisco devices and servers) software using SNMP and ICMP
i think i will stuck with the multiple backgroundworker solution
thanks for your help