Esempio n. 1
0
 public MultiPollerService(IEnumerable<Func<IService>> serviceFactories, TimeSpan reinitWait)
 {
     _reinitWait = reinitWait;
     _serviceFactories = serviceFactories.ToArray();
     _threads = new Thread[_serviceFactories.Length];
     _threadController = new ThreadController();
 }
Esempio n. 2
0
        protected override void Process(ThreadController myController)
        {
            myController.AddDelegate(delegate(object obj)
            {
                ClearPressedState();
                while (myEvent.Count != 0)
                {
                    if (myEvent.TryDequeue(out var aResult))
                    {
                        switch (aResult.type)
                        {
                        case SDL2.SDL.SDL_EventType.SDL_MOUSEMOTION:
                            UpdateMouseMovement(aResult);
                            break;

                        case SDL2.SDL.SDL_EventType.SDL_MOUSEBUTTONDOWN:
                            UpdateMouseButtonState(aResult);
                            break;

                        case SDL2.SDL.SDL_EventType.SDL_MOUSEBUTTONUP:
                            UpdateMouseButtonState(aResult);
                            break;

                        case SDL2.SDL.SDL_EventType.SDL_MOUSEWHEEL:
                            UpdateMouseWheelChange(aResult);

                            break;
                        }
                    }
                }
            });
        }
Esempio n. 3
0
 protected override void OnNavigatingFrom(MtNavigatingCancelEventArgs e)
 {
     base.OnNavigatingFrom(e);
     if (e.NavigationMode == NavigationMode.Back)
     {
         //mainGridThread.Children.Remove(myWebview);
         this.NavigationCacheMode = NavigationCacheMode.Disabled;
         helper           = null;
         bookMark         = null;
         thread           = null;
         myLogin          = null;
         define           = null;
         appSetting       = null;
         threadController = null;
         myWebview        = null;
         tbMessage.Text   = Resource.STR_EMPTY;
         if (wbPopup != null)
         {
             wbPopup.Navigate(new Uri("about:blank"));
             wbPopup = null;
         }
         _instance = null;
         GC.Collect();
     }
     else
     {
         if (wbPopup != null)
         {
             wbPopup.Navigate(new Uri("about:blank"));
         }
     }
 }
        public void Forum_ThreadController_Index_ShouldCallViewModelFactoryWithCorrectData(int atPosition, int expectedId)
        {
            // Arrange
            var data             = new Mock <IUowData>();
            var pagerFactory     = new Mock <IPagerViewModelFactory>();
            var viewModelFactory = new Mock <IViewModelFactory>();

            data.Setup(d => d.Threads.All()).Returns(TestThread().AsQueryable());
            data.Setup(d => d.Answers.All()).Returns(AnswersCollection().AsQueryable);

            Mapper.Initialize(cfg =>
            {
                cfg.CreateMap <Thread, ThreadViewModel>();
                cfg.CreateMap <Answer, AnswerViewModel>();
                cfg.CreateMap <Comment, CommentViewModel>();
            });

            var controller = new ThreadController(data.Object, pagerFactory.Object, viewModelFactory.Object);

            // Act
            var result = controller.Index(1) as ViewResult;

            // Assert
            viewModelFactory.Verify(p => p.CreateForumThreadViewModel(It.Is <ThreadViewModel>(t => t.Id == 1 && t.Published == new DateTime(2017, 01, 01)),
                                                                      It.Is <IEnumerable <AnswerViewModel> >(l => l.ElementAt(atPosition).Id == expectedId), null));
        }
        public void Forum_ThreadController_Index_ShouldCallPagerViewModelFactoryWithCorrectData(int page)
        {
            // Arrange
            var data             = new Mock <IUowData>();
            var pagerFactory     = new Mock <IPagerViewModelFactory>();
            var viewModelFactory = new Mock <IViewModelFactory>();

            data.Setup(d => d.Threads.All()).Returns(TestThread().AsQueryable());
            data.Setup(d => d.Answers.All()).Returns(AnswersCollection().AsQueryable);

            Mapper.Initialize(cfg =>
            {
                cfg.CreateMap <Thread, ThreadViewModel>();
                cfg.CreateMap <Answer, AnswerViewModel>();
                cfg.CreateMap <Comment, CommentViewModel>();
            });

            var controller = new ThreadController(data.Object, pagerFactory.Object, viewModelFactory.Object);

            // Act
            var result = controller.Index(1, page) as ViewResult;

            // Assert
            pagerFactory.Verify(p => p.CreatePagerViewModel("Thread", page, 6, WebConstants.PageSize));
        }
Esempio n. 6
0
        private void LogThread(ThreadController controller)
        {
            while (true)
            {
                if (commandsQueue.Count > 0)
                {
                    var command = commandsQueue.Dequeue();
                    switch (command.LogDestination)
                    {
                    case ELogDestination.File:
                        PrintToFile(command.Message);
                        break;

                    case ELogDestination.Console:
                        PrintToConsole(command.Message);
                        break;

                    case ELogDestination.All:
                        PrintToConsole(command.Message);
                        PrintToFile(command.Message);
                        break;
                    }
                }
                else
                {
                    controller.Pause();
                }
            }
        }
Esempio n. 7
0
        public ThreadView()
        {
            this.InitializeComponent();

            CurrentPage  = 1;
            appBar.Width = ActualWidth;

            btnPopupPostMessage.IsEnabled = false;
            BtnRating.IsEnabled           = false;
            comment.IsEnabled             = false;

            bookMark         = new BookmarkModelData();
            helper           = new HtmlHelper();
            thread           = new ThreadModel();
            myLogin          = new AccountHelper();
            define           = new DefineEmoticon();
            appSetting       = new AppSettingModel();
            threadController = new ThreadController();

            if (Windows.Foundation.Metadata.ApiInformation.IsPropertyPresent("Windows.UI.Xaml.FrameworkElement", "AllowFocusOnInteraction"))
            {
                fl_Page.AllowFocusOnInteraction     = true;
                tbMessage.AllowFocusOnInteraction   = true;
                jumpTextBox.AllowFocusOnInteraction = true;
                getIdthread.AllowFocusOnInteraction = true;
            }

            _instance = this;
            //this.NavigationCacheMode = NavigationCacheMode.Enabled;
        }
Esempio n. 8
0
        public void SetMosaicWindow(MosaicWindow window)
        {
            this.window      = window;
            this.imageViewer = window.TileView;

            InitializeComponent();

            this.SetStyle(
                ControlStyles.AllPaintingInWmPaint |
                ControlStyles.UserPaint |
                ControlStyles.ResizeRedraw |
                ControlStyles.Opaque |
                ControlStyles.DoubleBuffer, true);

            this.imageViewer.ZoomChanged       += new EventHandler(OnZoomChanged);
            this.imageViewer.VertScrollChanged += new ScrollEventHandler(OnVerticalScrollChanged);
            this.imageViewer.HorzScrollChanged += new ScrollEventHandler(OnHorizontalScrollChanged);
            this.imageViewer.PanningOccurred   += new TileViewHandler <TileView, EventArgs>(OnPanningOccurred);
            this.imageViewer.SizeChanged       += new EventHandler(OnImageViewSizeChanged);
            this.imageViewer.OnScrollChanged   += new ScrollEventHandler(OnScrollChanged);

            this.window.BlendingChanged +=
                new MosaicWindowHandler <MosaicWindow, MosaicWindowEventArgs>(OnBlendingChanged);

            this.Paint += new PaintEventHandler(OnPaint);

            threadController = new ThreadController(this);
            threadController.SetThreadCompletedCallback(TileOverviewThreadCompleted);
        }
Esempio n. 9
0
        static uint XInputSetState_Hooked(int dwUserIndex, ref Vibration pVibration)
        {
            try
            {
                ControllerReader myController = ControllerReader.Instance;

                if (myController.controllers.Count < dwUserIndex)
                {
                    return(ERROR_DEVICE_NOT_CONNECTED);
                }

                int leftVal  = ThreadController.iround(((float)pVibration.LeftMotorSpeed / 65535) * 255);
                int rightVal = ThreadController.iround(((float)pVibration.RightMotorSpeed / 65535) * 255);
                myController.controllers[dwUserIndex].Vibrate(0, 0, leftVal, rightVal, dwUserIndex);

                XboxOneControllerInjection This = (XboxOneControllerInjection)HookRuntimeInfo.Callback;

                lock (This.Queue)
                {
                    if (This.Queue.Count < 1000)
                    {
                        This.Queue.Push("XInputSetState dwUserIndex = " + dwUserIndex);
                    }
                }
            }
            catch
            {
                return(ERROR_DEVICE_NOT_CONNECTED);
            }
            return(ERROR_SUCCESS);
        }
Esempio n. 10
0
 void Start()
 {
     this._threadController    = new ThreadController();
     this._thread              = new Thread(ReceiveThread);
     this._thread.IsBackground = true;
     this._thread.Start(this._threadController);
 }
Esempio n. 11
0
 public void Run(ThreadController myController)
 {
     if (SystemToggle)
     {
         Process(myController);
     }
 }
Esempio n. 12
0
        public CCTimer(ITagOp tagOp, string tagName,
                       string outTagName, int onLast = 1000,
                       string offOutTagName          = "", int offLast = 1000)
            : base(tagName)
        {
            TagOp     = tagOp;
            OnLastMs  = onLast;
            OffLastMs = offLast;
            Func <bool?> check = () => {
                if (tagOp != null)
                {
                    return(tagOp.ReadBit(tagName));
                }
                else
                {
                    return(null);
                }
            };

            Name      = $"{tagName}-{outTagName}:{onLast}-{offOutTagName}:{offLast}";
            CheckFunc = check;
            OnLastMs  = onLast;
            OffLastMs = offLast;

            ThreadStart = new ControlledThreadStart(RunCheck);

            ThreadController = new ThreadController(ThreadStart, null, Name);

            StartThread();

            OutTag         = outTagName;
            OffOutTag      = offOutTagName;
            OutChanged    += Task_OutChanged;
            OffOutChanged += Task_OffOutChanged;
        }
        public ThreadControllerTests()
        {
            var mockLogger = new Mock <ILogger <ThreadController> >();

            _mockPostService = new Mock <IPostService>();
            _controller      = new ThreadController(mockLogger.Object, _mockPostService.Object);
        }
Esempio n. 14
0
        private void RunPY(ThreadController controller, object state)
        {
            Engine.SetTrace(OnTracebackReceived);
            //ObjectOperations operations = Engine.CreateOperations(Scope);


            while (true)
            {
                try
                {
                    LastStartTime = DateTime.Now;

                    if (FirstRun)
                    {
                        FirstRun = false;
                    }

                    PythonFunction RunOneTimeAction = (PythonFunction)GetVariable("RunOneTime");
                    PythonCalls.Call(codeContext, RunOneTimeAction);

                    RunTimes++;
                    LastFinishTime = DateTime.Now;
                }catch (Exception ex)
                {
                }
            }
        }
Esempio n. 15
0
 public ThreadLoader(Post post, ApiConfig config)
 {
     _post             = post;
     resolver          = new ReferenceResolver();
     _config           = config;
     _threadController = new ThreadController(_config);
     PageSize          = _threadController.PageSize;
 }
Esempio n. 16
0
 public MultiPoller(IContainer container, IEnumerable<string> pollerNames, TimeSpan reinitWait)
 {
     _container = container;
     _pollerNames = pollerNames.ToArray();
     _reinitWait = reinitWait;
     _threads = new Thread[_pollerNames.Length];
     _threadController = new ThreadController();
 }
Esempio n. 17
0
//88888
//       public Service1(object caller)
        public Service1()
        {
            InitializeComponent();

//88888
            theController = new ThreadController(this);
//            theController = new ThreadController();
        }
Esempio n. 18
0
 private void Execute()
 {
     //Prevents suspending because of incorrectly Shell-commands
     ThreadController.ExecuteCommandThread(() =>
     {
         Log          = $"{Log}{Environment.NewLine}{cracker.Execute(ADBCommands.EXECUTE, CommandInput)}";
         CommandInput = String.Empty;
     });
 }
Esempio n. 19
0
        public void SaveCache()
        {
            saveCacheThreadController = new ThreadController(this);
            saveCacheThreadController.SetThreadCompletedCallback(SaveFileThreadCompleted);
            saveCacheThreadController.SetThreadProgressCallback(SaveFileProgressIndicator);

            TileSaver saver = new TileSaver(saveCacheThreadController, this);

            saver.SaveCacheFile();
        }
Esempio n. 20
0
        static void Main(string[] args)
        {
            Console.ReadKey();
            var controller = new ThreadController();

            controller.Processes.Add(new Animation1("animation_1"));
            controller.Processes.Add(new Animation2("animation_2"));
            controller.Processes.Add(new Animation3("animation_3"));
            controller.StartAll();
        }
Esempio n. 21
0
    public void Start()
    {
        threadController = new ThreadController {
            ShouldExecute = true
        };
        Thread receiveThread = new Thread(ReceiveData);

        receiveThread.IsBackground = true;
        receiveThread.Start(threadController);
    }
Esempio n. 22
0
 public MainWindow()
 {
     ThreadController.SetDispatcher(Dispatcher);
     StartStopReadCommand = new CommandDelegate {
         ExecuteHandler = StartStopRead
     };
     InitializeComponent();
     DataContext = ViewModel ??= new ViewModel();
     Console.SetOut(new StormbusTextWriter(LogTextBox));
 }
Esempio n. 23
0
        private void RatingMethod(int rating)
        {
            bool checkDone = false;

            ThreadController.SendRating(rating, idThread, ref checkDone);
            if (checkDone)
            {
                Loader();
            }
        }
Esempio n. 24
0
 public override void WriteLine(string value)
 {
     ThreadController.InvokeToMain(() =>
     {
         _textBox.Select(_textBox.Text.Length + 1, 0);
         _textBox.AppendText("[" + DateTime.Now.TimeOfDay + "] > ");
         _textBox.AppendText(value);
         _textBox.AppendText(Environment.NewLine);
         _textBox.ScrollToEnd();
     });
 }
Esempio n. 25
0
        private void Export()
        {
            ThreadController threadController = new ThreadController(this);

            threadController.SetThreadCompletedCallback(SaveFileThreadCompleted);
            threadController.SetThreadProgressCallback(SaveFileProgressIndicator);

            TileSaver saver = new TileSaver(threadController, this);

            saver.Export();
        }
Esempio n. 26
0
        private void GetContenFromQuote(string urlQuote)
        {
            HtmlDocument docQuote    = new HtmlDocument();
            string       contentHtml = string.Empty;

            ThreadController.GetContent(urlQuote, ref contentHtml);
            docQuote.LoadHtml(contentHtml);
            var contentQuote = (from tx in docQuote.DocumentNode.Descendants("textarea") where (tx.GetAttributeValue("id", "") == "vB_Editor_001_textarea") select tx).FirstOrDefault();

            tbComment.Text = HtmlEntity.DeEntitize(contentQuote.InnerText.Trim());
        }
Esempio n. 27
0
        private async void Loader()
        {
            lv_Post.IsEnabled = false;
            pgRing.IsActive   = true;
            tbComment.Text    = string.Empty;

            try
            {
                doc = new HtmlAgilityPack.HtmlDocument();
                await Task.Run(() => ThreadController.GetContent(url, ref contentHtml));

                doc.LoadHtml(contentHtml);
                Hap.RemoveComment(doc);
                Hap.AnalyzeEmoticon(doc);
                Hap.RemoveQuoteButton(doc);

                if (!string.IsNullOrEmpty(appSetting.token))
                {
                    if (appSetting.token == "guest")
                    {
                        tbComment.IsEnabled   = false;
                        sentMessage.IsEnabled = false;
                        btnEmoticon.IsEnabled = false;
                    }
                    else
                    {
                        tbComment.IsEnabled   = true;
                        btnEmoticon.IsEnabled = true;
                    }
                }
                else
                {
                    tbComment.IsEnabled   = false;
                    sentMessage.IsEnabled = false;
                    btnEmoticon.IsEnabled = false;
                }

                GetMaxPage();
                GetTitleThread();
                GetComment();
                CheckRate();
                if (string.IsNullOrEmpty(mxp) == false)
                {
                    mxp = mxp.Replace("of", "/").Replace("Page", string.Empty).Replace(" ", string.Empty).Trim();
                }
                fl_page_btnflyout.DataContext = mxp;
                fly_PanelEmoticon.Hide();
            }
            catch (Exception ex)
            {
                LogError("Lỗi mạng: \n * Kiểm tra lại kết nối, DNS \n * Có thể lỗi máy chủ. \n *********** \n Chi tiết lỗi: \n" + ex.ToString());
            }
        }
 protected override void Process(ThreadController myController)
 {
     myController.AddDelegate(delegate(Object obj)
     {
         while (myEvent.Count != 0)
         {
             if (myEvent.TryDequeue(out var aResult))
             {
                 ProcessEvent(aResult);
             }
         }
     });
 }
Esempio n. 29
0
        public void InitR()
        {
            Engine = Python.CreateEngine();
            Scope  = Engine.CreateScope();
            ICollection <string> sps = Engine.GetSearchPaths();

            sps.Add(@"D:\Program Files (x86)\Siemens\Automation\WinCC RT Advanced\IRONPYTHON");
            Engine.SetSearchPaths(sps);

            ThreadStart = new ControlledThreadStart(RunPY);

            ThreadController = new ThreadController(ThreadStart, null, Name);
        }
Esempio n. 30
0
 protected void RunCheck(ThreadController controller, object state)
 {
     while (true)
     {
         try
         {
             RunOneTime();
         }
         catch (Exception ex)
         {
         }
     }
 }
Esempio n. 31
0
        /// <summary>
        /// 计时器
        /// </summary>
        /// <param name="name">名称</param>
        /// <param name="check">检查方法</param>
        /// <param name="lastMs">持续时间</param>
        /// <param name="offLast">反扶持时间</param>
        public YZXTimerTask(string name, Func <bool?> check, int lastMs = 1000, int offLast = 1000)
        {
            Name      = name;
            CheckFunc = check;
            OnLastMs  = lastMs;
            OffLastMs = offLast;

            ThreadStart = new ControlledThreadStart(RunCheck);

            ThreadController = new ThreadController(ThreadStart, null, Name);

            StartThread();
        }
 protected sealed override void Process(ThreadController myController)
 {
     if (myController != null)
     {
         myController.AddDelegate(delegate(Object A)
         {
             Process(myReference, myReferenceOther);
         });
     }
     else
     {
         Process(myReference, myReferenceOther);
     }
 }