Esempio n. 1
0
        private void addCameraWatch(string cameraName, bool selectIfFound)
        {
            Delegate subscribeForEntity = new ThreadStart(delegate()
            {
                try
                {
                    SimulationEngine.GlobalInstancePort.Subscribe(new EntitySubscribeRequestType()
                    {
                        Name = cameraName
                    }, _notifyTarget);
                    Arbiter.Activate(queue, Arbiter.Receive <InsertSimulationEntity>(true, _notifyTarget,
                                                                                     delegate(InsertSimulationEntity ins) { AddCamera(ins.Body as CameraEntity, selectIfFound); }));
                }
                catch (Exception e)
                {
                    Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal,
                                      new ThreadStart(delegate() { GUIUtilities.ReportUnexpectedException(e); }));
                }
            });

            if (_notifyTarget != null && SimulationEngine.GlobalInstancePort != null)
            {
                Arbiter.Activate(queue, Arbiter.Choice(
                                     SimulationEngine.GlobalInstancePort.Query(
                                         new VisualEntity()
                {
                    EntityState = new EntityState()
                    {
                        Name = cameraName
                    }
                }),
                                     delegate(QuerySimulationEntityResponseType r)
                {
                    if (r.Entity != null)
                    {
                        var cam = r.Entity as CameraEntity;
                        if (cam != null)
                        {
                            AddCamera(cam, selectIfFound);
                        }
                        else
                        {
                            subscribeForEntity.DynamicInvoke();
                        }
                    }
                    else
                    {
                        subscribeForEntity.DynamicInvoke();
                    }
                },
                                     delegate(Fault f)
                {
                    subscribeForEntity.DynamicInvoke();
                }));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// ThreadStart를 try-catch 구문 안에서 실행시킨다.
        /// </summary>
        private void MultiThreadedWorker()
        {
            try {
                _userDelegate.DynamicInvoke();
            }
            catch (Exception ex) {
                if (log.IsWarnEnabled)
                {
                    log.WarnException("예외가 발생했습니다.", ex);
                }

                _lastException = ex;
            }
        }
Esempio n. 3
0
        private void Timer_Tick(object sender, System.EventArgs e)
        {
            if (Ticker != null)
            {
                Ticker.Tick -= Timer_Tick;
                Ticker.Stop();
                Ticker.Dispose();
                Ticker = null;
            }

            if (threadStart != null)
            {
                result = threadStart.DynamicInvoke(threadArgs);
            }
            else
            {
                result = null;
            }

            this.Dispose();
        }
Esempio n. 4
0
        private void startThreadSearch(ThreadStart task)
        {
            _tSearch = new Thread(() =>
            {
                try
                {
                    this.Cursor = Cursors.WaitCursor;

                    btnFindAll.Enabled       = false;
                    btnFindNext.Enabled      = false;
                    btnReplace.Enabled       = false;
                    btnReplaceAll.Enabled    = false;
                    txtFind.Enabled          = false;
                    txtReplace.Enabled       = false;
                    gbSearchIn.Enabled       = false;
                    chkCaseSensitive.Enabled = false;
                    btnStopSearch.Enabled    = true;

                    task.DynamicInvoke(null);
                }
                finally
                {
                    btnFindAll.Enabled       = true;
                    btnFindNext.Enabled      = true;
                    btnReplace.Enabled       = true;
                    btnReplaceAll.Enabled    = true;
                    txtFind.Enabled          = true;
                    txtReplace.Enabled       = true;
                    gbSearchIn.Enabled       = true;
                    chkCaseSensitive.Enabled = true;
                    btnStopSearch.Enabled    = false;

                    this.Cursor = Cursors.Default;
                }
            });
            _tSearch.Start();
        }
Esempio n. 5
0
 private void addCameraWatch(string cameraName, bool selectIfFound)
 {
     Delegate subscribeForEntity = new ThreadStart(delegate()
     {
         try
         {
             SimulationEngine.GlobalInstancePort.Subscribe(new EntitySubscribeRequestType() { Name = cameraName }, _notifyTarget);
             Arbiter.Activate(queue, Arbiter.Receive<InsertSimulationEntity>(true, _notifyTarget,
                 delegate(InsertSimulationEntity ins) { AddCamera(ins.Body as CameraEntity, selectIfFound); }));
         }
         catch (Exception e)
         {
             Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal,
                 new ThreadStart(delegate() { GUIUtilities.ReportUnexpectedException(e); }));
         }
     });
     if (_notifyTarget != null && SimulationEngine.GlobalInstancePort != null)
     {
         Arbiter.Activate(queue, Arbiter.Choice(
             SimulationEngine.GlobalInstancePort.Query(
                 new VisualEntity() { EntityState = new EntityState() { Name = cameraName } }),
             delegate(QuerySimulationEntityResponseType r)
             {
                 if (r.Entity != null)
                 {
                     var cam = r.Entity as CameraEntity;
                     if (cam != null)
                         AddCamera(cam, selectIfFound);
                     else
                         subscribeForEntity.DynamicInvoke();
                 }
                 else
                     subscribeForEntity.DynamicInvoke();
             },
             delegate(Fault f)
             {
                 subscribeForEntity.DynamicInvoke();
             }));
     }
 }
Esempio n. 6
0
 public static void ProfileCall(ThreadStart threadStart, string sampleName)
 {
     Profiler.BeginSample(sampleName);
     threadStart.DynamicInvoke();
     Profiler.EndSample();
 }