private void AddStatusString(string newText) { // InvokeRequired required compares the thread ID of the // calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. if (this.labelOutputStatus.InvokeRequired) { AddStatusTextCallback d = new AddStatusTextCallback(AddStatusString); this.Invoke(d, new object[] { newText }); } else { labelOutputStatus.Text = newText; Refresh(); } }
public void Start() { try { TheSystem = ActorSystem.Create( "TheSystem" ); Running = true; int MaxActor = Convert.ToInt32( tbActorCount.Text ); Func<Action<int, string>> callback_CreateProgressBar = () => { var d = new CreateProgressBarCallback( CreateProgressBar ); return (Action<int, string>)Invoke( d, new object[] { } ); }; var props = Props.Create( () => new WorkActor( callback_CreateProgressBar ) ).WithRouter( new SmallestMailboxPool( MaxActor ) ); var router = TheSystem.ActorOf( props, "router" ); Func<Action<string>> callback_AddStatusText = () => { var d = new AddStatusTextCallback( AddStatusText ); return (Action<string>)Invoke( d, new object[] { } ); }; props = Props.Create( () => new ProgressActor( callback_AddStatusText ) ); var progress = TheSystem.ActorOf( props, "progress" ); Console.WriteLine( progress.Path ); var start = Convert.ToInt32( tbStart.Text ); var end = Convert.ToInt32( tbEnd.Text ); for (int i = start; i <= end; i++) { router.Tell( i ); } } catch (Exception e) { Running = false; MessageBox.Show( e.Message, "Error" ); } }