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... } }
No comments:
Post a Comment