daily pastebin goal
26%
SHARE
TWEET

Untitled

a guest Dec 3rd, 2011 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Threading;
  3. using System.Threading.Tasks;
  4.  
  5. namespace WindowsFormsApplication2
  6. {
  7.     public delegate void ChangedEventHandler(object sender, EventArgs e);
  8.  
  9.     public class WorkLongTime
  10.     {
  11.         public event ChangedEventHandler Changed;
  12.  
  13.         protected virtual void OnChanged(EventArgs e)
  14.         {
  15.             if (Changed != null)
  16.                 Changed(this, e);
  17.         }
  18.  
  19.         public void WorkLong()
  20.         {
  21.             string[] myLittleArray = new string[10] {"abc","abc","abc","abc","abc","abc","abc","abc","abc","abc"};
  22.             Parallel.ForEach(myLittleArray, singleString =>
  23.                 {
  24.                     Thread.Sleep(500);
  25.                     OnChanged(EventArgs.Empty);
  26.                 });
  27.         }
  28.     }
  29. }
  30.  
  31.  
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top