0
Posted on 7:33 AM by Softminer and filed under ,

class Program
{
  static BackgroundWorker _bw = new BackgroundWorker();
 
  static void Main()
  {
    _bw.DoWork += TODO;
    _bw.RunWorkerAsync("Message to worker");
    Console.ReadLine();
  }
 
  void TODO(object sender, DoWorkEventArgs e)
  {
    // This is called on the worker thread
    // writes "Message to worker"
    Console.WriteLine (e.Argument);    
            _backgroundworker.CancelAsync();    
    // Perform time-consuming task...
  }
}
0
Responses to ... How to run .net process on background to avoid GUI hanging