public MasterAPI(string[] pcsUrls) { Servers = new ConcurrentDictionary <string, IServer>(); ServerUrls = ""; ServerIdsToUrls = new ConcurrentDictionary <string, string>(); Clients = new ConcurrentDictionary <string, IClient>(); PCSs = new ConcurrentDictionary <string, ProcessCreationService>(); foreach (string url in pcsUrls) { PCSs.TryAdd(BaseUrlExtractor.Extract(url), (ProcessCreationService)Activator.GetObject(typeof(ProcessCreationService), url)); } _startProcessDelegate = new StartProcessDelegate(StartProcess); _serverDelegate = new ServerDelegate(ServerSync); _clientDelegate = new ClientDelegate(ClientSync); _addRoomDelegate = new AddRoomDelegate(AddRoomSync); _statusDelegate = new StatusDelegate(StatusSync); _crashDelegate = new CrashDelegate(CrashSync); _freezeDelegate = new FreezeDelegate(FreezeSync); _unfreezeDelegate = new UnfreezeDelegate(UnfreezeSync); _shutDownSystemDelegate = new ShutDownSystemDelegate(ShutDownSystemSync); _checkNodeStatusDelegate = new CheckNodeStatus(CheckNode); _nodesCreated = 0; }
private void StartButton_Click(object sender, System.EventArgs e) { StartProcessDelegate progDel = new StartProcessDelegate(StartProcess); progDel.BeginInvoke(100, null, null); MessageBox.Show("Done with operation!!"); }
private void StartButton_Click(object sender, EventArgs e) { var progDelegate = new StartProcessDelegate(StartProcess); progDelegate.BeginInvoke(100, null, null); Console.WriteLine("Done With operation"); }
private void Btn_Start_Click(object sender, EventArgs e) { //var progDelBad = new StartProcessDelegate(StartProcessBad); var progDelGood = new StartProcessDelegate(StartProcessGood); //progDelBad.BeginInvoke( 100, null, null ); progDelGood.BeginInvoke(100, null, null); }
public void StartServer(StartProcessDelegate startProcess) { _outServer = new AnonymousPipeServerStream(PipeDirection.Out, HandleInheritability.Inheritable); _inServer = new AnonymousPipeServerStream(PipeDirection.In, HandleInheritability.Inheritable); _readStream = new StreamString(_inServer); _writeStream = new StreamString(_outServer); startProcess(_outServer.GetClientHandleAsString(), _inServer.GetClientHandleAsString()); _outServer.DisposeLocalCopyOfClientHandle(); _inServer.DisposeLocalCopyOfClientHandle(); }
private void StartButton_Click(object sender, EventArgs e) { // Call long running process StartProcessDelegate startDel = new StartProcessDelegate(StartProcess); // startDel.BeginInvoke executes delegate on new thread startDel.BeginInvoke(100, null, null); // Show message box to demonstrate that StartProcess() // is running asynchronously MessageBox.Show("Called after async process started."); }
private void StartButton_Click(object sender, RoutedEventArgs e) { //Call long running process StartProcessDelegate startDel = new StartProcessDelegate(StartProcess); //startDel.BeginInvoke executes delegate on new thread startDel.BeginInvoke(100, null, null); //Show message box to demonstrate that StartProcess() //is running asynchronously MessageBox.Show("Called after async process started."); }
public void StartServer(StartProcessDelegate startProcess, bool disposeLocalClientHandle = true) { ArgUtil.NotNull(startProcess, nameof(startProcess)); _outServer = new AnonymousPipeServerStream(PipeDirection.Out, HandleInheritability.Inheritable); _inServer = new AnonymousPipeServerStream(PipeDirection.In, HandleInheritability.Inheritable); _readStream = new StreamString(_inServer); _writeStream = new StreamString(_outServer); startProcess(_outServer.GetClientHandleAsString(), _inServer.GetClientHandleAsString()); if (disposeLocalClientHandle) { _outServer.DisposeLocalCopyOfClientHandle(); _inServer.DisposeLocalCopyOfClientHandle(); } }
private void btnStart_Click(object sender, System.EventArgs e) { int max = 100; this.pbStatus.Maximum = max; //Call long running process StartProcessDelegate startDel = new StartProcessDelegate(StartProcess); //startDel.BeginInvoke executes delegate on new thread startDel.BeginInvoke(max, null, null); //Show message box to demonstrate that StartProcess() //is running asynchronously MessageBox.Show("Called after async process started."); }
// 开始爬取数据 public void start_craw(object sender, EventArgs e) { string goods_name, goods_unit, goods_url, price_xpath; goods_name = textBox1.Text; goods_unit = textBox2.Text; goods_url = textBox3.Text; price_xpath = textBox4.Text; string[] the_args = { goods_name, goods_unit, goods_url, price_xpath }; StartProcessDelegate la = new StartProcessDelegate(StartProcess); // 创建委托 //StartProcess(exe_path, the_args); Invoke(la, exe_path, the_args); }
public CFormExecuteProcess() { // // Requis pour la prise en charge du Concepteur Windows Forms // InitializeComponent(); // // TODO : ajoutez le code du constructeur après l'appel à InitializeComponent // m_repriseAction += new RepriseActionDelegate(RepriseActionPrivate); m_startProcess += new StartProcessDelegate(StartProcessPrivate); m_startProcessMultiples += new StartProcessMultiplesDelegate(StartProcessMultiplesPrivate); m_runEvent += new RunEventDelegate(RunEventPrivate); m_runEventMultiples += new RunEventMultiplesDelegate(RunEventMultiplesPrivate); }
private void ShowProgress(int i) { //On helper thread so invoke on UI thread to avoid //updating UI controls from alternate thread if (lblOutput.InvokeRequired == true) { var del = new StartProcessDelegate(ShowProgress); //this.BeginInvoke executes delegate on thread used by form (UI thread) this.BeginInvoke(del, i); } else { //On UI thread so we are safe to update progressBar1.Value = i; label1.Text = i.ToString(); } }
private void StartProcess() { if (progressBar1.InvokeRequired) // switch from one thread to another { var del = new StartProcessDelegate(StartProcess); // do call from gui thread to non gui this.Invoke(del); } else { // will fail if execute the code from GUI thread this.Refresh(); this.progressBar1.Maximum = _Max; for (int i = 0; i <= _Max; i++) { Thread.Sleep(10); this.labelOutput.Text = i.ToString(); this.progressBar1.Value = i; } } }
private void StartButton_Click(object sender, EventArgs e) { var progDel = new StartProcessDelegate(StartProcess); progDel.BeginInvoke(10, null, null); ///invoce asyncronously }