Esempio n. 1
0
        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!!");
        }
Esempio n. 3
0
        private void StartButton_Click(object sender, EventArgs e)
        {
            var progDelegate = new StartProcessDelegate(StartProcess);

            progDelegate.BeginInvoke(100, null, null);
            Console.WriteLine("Done With operation");
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
 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();
 }
Esempio n. 6
0
 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.");
        }
Esempio n. 9
0
 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();
     }
 }
Esempio n. 10
0
        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.");
        }
Esempio n. 11
0
        // 开始爬取数据
        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);
        }
Esempio n. 12
0
        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);
        }
Esempio n. 13
0
 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();
     }
 }
Esempio n. 14
0
 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;
         }
     }
 }
Esempio n. 15
0
        private void StartButton_Click(object sender, EventArgs e)
        {
            var progDel = new StartProcessDelegate(StartProcess);

            progDel.BeginInvoke(10, null, null);  ///invoce asyncronously
        }