Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2011
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.78 KB | None | 0 0
  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.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement