I have two threads, one UI thread and one Background thread..
I want to keep a track of the background thread so that I may kill my UI thread (a tray icon) when the background thread has finished...
Please review my code for more details..
Code:class Program { static void Main(string[] args) { Thread[] threads = new Thread[2]; threads[0] = new Thread(new ThreadStart(UIMethod)); threads[1] = new Thread(new ThreadStart(BackGroundMethod)); threads[0].SetApartmentState(ApartmentState.STA); threads[0].Start(); threads[1].Start(); /*What should I write here so that I know when BackGroundMethod has finished, I can kill my system tray icon*/ } public static void UIMethod() { /*Generate the system tray*/ Tray obj = new Tray(); obj.GenerateTrayIcon(); Application.Run(); } public static void BackGroundMethod() { /*Do some heavy background work..*/ } }
Any suggestions with some code would be highly appreciated..
Thanks.




Reply With Quote