Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // worker
- class Worker
- {
- public Action<string> OnComplete;
- public Worker( Action<string> _aOnComplete )
- {
- OnComplete = _aOnComplete;
- }
- public Start( int _iNumber )
- {
- Thread.Sleep( 2000 );
- OnComplete?.Invoke( "Worker #{_iNumber.ToString()} finished." );
- }
- }
- // ui
- class MainForm : System.Windows.Forms.Forms
- {
- // ui zeug
- public void Initialize()
- {
- for( int i = 0; i < 100; i++ )
- {
- Worker w = new Worker( ( string _pszMsg ) => { TextBox1.Invoke( new MethodInvoker( () => { TextBox1.Text += "{_pszMsg}\n" } ) ) } );
- w.Start( i );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement