Oppps DynamicInvoke was a test to see if it would work better so here's the original version :
textBoxLog is err.... a textBoxCode:private static void OnStatusChanged(EventPourUpdateLog e) { StatusChangedEventHandler statusHandler = StatusChanged; if (statusHandler != null) { // Invoque le délégué statusHandler(null, e); //statusHandler.DynamicInvoke(null, e); } }
No exception thrown. Breakpoint and stepinto just go in freeze when reaching UpdateLog
Ok let's try your method, here's the piece of code failing let's see how commenting changes it.
I'll follow your commeting scenario : Serveur.UpdateLog(string) --> Serveur.OnStatusChanged(...) --> /* via event */ --> FauxServeur.StatusChanged(...) --> FauxServeur.UpdateLog(string) --> textBoxLog.AppendText(string)Code:1. Console.WriteLine("1"); 2. UpdateLog("[INFO] Fermeture listener" + Environment.NewLine); 3. Console.WriteLine("2"); 4. myListener.Stop(); 5. Console.WriteLine("3"); 6. UpdateLog("[INFO] Listener fermé" + Environment.NewLine); 7. Console.WriteLine("4"); 8. FermetureListener.Set(); 9. Console.WriteLine("5");
Of course I uncomment the previous each time.
1st case : nothing commented
Last line executed was line 5
2nd case : commenting line 6
Complete execution. Line 9 was executed
3rd case : commenting Serveur.OnStatusChanged(...) inside the Serveur.UpdateLog function
Complete execution. Line 9 was executed
4th case : commenting statusHandler(null, e); inside Serveur.OnStatusChanged
Complete execution. Line 9 was executed
5th case : commenting this.Invoke(new DeleguePourUpdateLog(this.UpdateLog), new object[] { e.message }); inside FauxServeur.StatusChanged()
Complete execution. Line 9 was executed
6th case : commenting textBoxLog.AppendText(s); inside FauxServeur.UpdateLog()
Line 3 never reached going further inside to find where it stopped
This is Serveur.UpdateLog()
Console.WriteLine("23"); is never reached. Going further inside.Code:public static void UpdateLog(String Message) { Console.WriteLine("21"); e = new EventPourUpdateLog(Message); Console.WriteLine("22"); OnStatusChanged(e); Console.WriteLine("23"); }
This is Serveur.OnStatusChanged
Console.WriteLine("33"); is never reached. Going further inside.Code:private static void OnStatusChanged(EventPourUpdateLog e) { Console.WriteLine("30"); StatusChangedEventHandler statusHandler = StatusChanged; Console.WriteLine("31"); if (statusHandler != null) { Console.WriteLine("32"); // Invoque le délégué statusHandler(null, e); Console.WriteLine("33"); //statusHandler.DynamicInvoke(null, e); } }
This is FauxServeur.StatusChanged()
Console.WriteLine("41"); is never reached. Going further inside.Code:public void StatusChanged(object sender, EventPourUpdateLog e) { Console.WriteLine("40"); this.Invoke(new DeleguePourUpdateLog(this.UpdateLog), new object[] { e.message }); Console.WriteLine("41"); }
Here is in this case the code for FauxServeur.UpdateLog()
Console.WriteLine("50"); is never reached canno't go further :/Code:private void UpdateLog(String s) { Console.WriteLine("50"); //textBoxLog.AppendText(s); Console.WriteLine("51"); }
Any idea ? for the moment the programs runs by being executed in case n°2
Thanks !





Reply With Quote