Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Threading;
- using System.Threading.Tasks;
- namespace WindowsFormsApplication2
- {
- public delegate void ChangedEventHandler(object sender, EventArgs e);
- public class WorkLongTime
- {
- public event ChangedEventHandler Changed;
- protected virtual void OnChanged(EventArgs e)
- {
- if (Changed != null)
- Changed(this, e);
- }
- public void WorkLong()
- {
- string[] myLittleArray = new string[10] {"abc","abc","abc","abc","abc","abc","abc","abc","abc","abc"};
- Parallel.ForEach(myLittleArray, singleString =>
- {
- Thread.Sleep(500);
- OnChanged(EventArgs.Empty);
- });
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement