BackGroundworker et events
Bonjour,
J'ai un petit problème d'évènements dans un backgroundworker.
J'ai la classe suivante :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
class MonControl : UserControl
{
private static UnType monObjet = new Untype();
private UnAutreType monAutreObjet = new UnAutreType();
private BackGroundWorker monBgw;
public MonControl()
{
initializeComponent();
}
public void uneMethode ()
{
List<Object> listParam = new List<Object>();
listParam.Add(monObjet );
listParam.Add(monAutreObjet );
monBgw.RunWorkerAsync(listParam);
}
private void voteBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
{
List<object> listArg = (e.Argument as List<object>);
UnType monObjetCopy = (listArg[0] as UnType);
UnAutreType monAutreObjetCopy = (listArg[1] as UnAutreType);
monObjetCopy += new OnEventUntypeObjetEventHandler(monObjetCopy_OnEvent);
}
void monObjetCopy_OnEvent(Arg mesArguments)
{
//Problème : Comment faire pour accéder à mesArguments dans le DoWork ?
}
} |
Voilà le problème. La solution est peut être dans les méthodes anonymes car je crois qu'elles accèdent aux variables et objets de la méthode où elles sont appelées.
Si vous avez une solution n'hesitez pas !
Merci.