Beispiel #1
0
            /// <param name="task">アクティビティのタスク</param>
            /// <param name="handler">タスク終了時のイベントハンドラ</param>
            /// <returns>アクティビティスレッド</returns>
            protected Thread Create(ActivityTask task, ActivityEventHandler handler)
            {
                ThreadStart start = new ThreadStart(delegate
                {
                    ActivityEventArgs args = new ActivityEventArgs();
                    try
                    {
                        task();
                        args.IsCompleted = true;
                    }
                    catch (ThreadAbortException ex)
                    {
                        args.IsAborted = true;
                        args.Exception = ex;
                    }
                    catch (Exception ex)
                    {
                        args.Exception = ex;
                    }
                    finally
                    {
                        MotorControler mc = MotorControler.GetInstance(parameterManager);
                        mc.AbortMoving();
                        mc.SlowDownStopAll();

                        if (handler != null)
                        {
                            handler(this, args);
                        }
                    }
                });

                return(Create(start));
            }
Beispiel #2
0
        void MotorKeyHandler_Unloaded(object sender, System.Windows.RoutedEventArgs e)
        {
#if !_NoHardWare
            MotorControler mc = MotorControler.GetInstance(parameterManager);
            mc.AbortMoving();
            mc.SlowDownStopAll();
#endif
        }
Beispiel #3
0
        public List <Thread> CreateTask()
        {
            List <Thread> taskList = new List <Thread>();

            taskList.Add(Create(new ThreadStart(delegate {
                try {
                    task();
                } catch (ThreadAbortException ex) {
                } finally {
                    MotorControler mc = MotorControler.GetInstance();
                    mc.AbortMoving();
                    mc.SlowDownStopAll();
                }
            })));
            return(taskList);
        }
Beispiel #4
0
        public List <Thread> CreateTask()
        {
            List <Thread> taskList = new List <Thread>();

            taskList.Add(Create(new ThreadStart(delegate {
                try {
                    task();
                } catch (ThreadAbortException ex) {
                } finally {
                    MotorControler mc = MotorControler.GetInstance();
                    mc.AbortMoving();
                    mc.SlowDownStopAll();
                }
            })));
            //SurfaceLanding sl = new SurfaceLanding(parameterManager);
            //taskList.AddRange(sl.CreateTask());
            return(taskList);
        }
Beispiel #5
0
            /// <summary>
            /// 撮影を開始します.
            /// </summary>
            /// <exception cref="System.ArgumentOutOfRangeException"></exception>
            /// <exception cref="InActionException"></exception>
            /// <exception cref="MotorActiveException"></exception>
            public void Start()
            {
                MotorControler mc = MotorControler.GetInstance(parameterManager);

                if (mc.IsMoving)
                {
                    throw new MotorActiveException();
                }
                if (IsActive)
                {
                    throw new InActionException();
                }
                if (interval <= 0)
                {
                    throw new ArgumentOutOfRangeException(Properties.Strings.ValMustPositiveNotZero);
                }


                shootingThread = Create(new ThreadStart(delegate() {
                    ActivityEventArgs eventArgs = new ActivityEventArgs();
                    try {
                        shootingThreadTask();
                        eventArgs.IsCompleted = true;
                    } catch (ThreadAbortException ex) {
                        eventArgs.IsAborted = true;
                        eventArgs.Exception = ex;
                    } catch (Exception ex) {
                        eventArgs.IsCompleted = false;
                        eventArgs.Exception   = ex;
                    } finally {
                        mc.SlowDownStopAll();

                        if (Exited != null)
                        {
                            Exited(this, eventArgs);
                        }
                    }
                }));
                shootingThread.IsBackground = true;
                shootingThread.Start();
            }