Exemple #1
0
        /// <summary>
        /// Called when [rendering].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void OnRendering(object sender, EventArgs e)
        {
            if (this.isDirty)
            {
                if (this.LowPriorityRendering)
                {
                    // if we called render previously...
                    if (this.previousRenderCall != null)
                    {
                        var previousStatus = this.previousRenderCall.Status;

                        // ... and the operation didn't finish yet - then skip the current call
                        if (previousStatus == System.Windows.Threading.DispatcherOperationStatus.Pending ||
                            previousStatus == System.Windows.Threading.DispatcherOperationStatus.Executing)
                        {
                            return;
                        }
                    }

                    this.previousRenderCall = this.Dispatcher.BeginInvoke(this.renderDelegate, System.Windows.Threading.DispatcherPriority.Input);
                }
                else
                {
                    this.renderDelegate();
                }

                this.IsDirty = this.AutoRender;
            }
        }
Exemple #2
0
 public void BeginUpdateLayout()
 {
     if (updateLayoutOperation == null || updateLayoutOperation.Status == DispatcherOperationStatus.Completed)
     {
         updateLayoutOperation = Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, (Action)UpdateLayout);
     }
 }
 /// <summary>
 ///     Cancels a pending DispatcherOperation
 /// </summary>
 internal void Cancel()
 {
     if (IsPending)
     {
         _operation.Abort();
     }
     _operation = null;
 }
        public void InvokeParametersTest()
        {
            int value = 0;

            DispatcherOperation operation0 = new DispatcherOperation(() => value = 1);
            operation0.Invoke();
            Assert.AreEqual(1, value);
        }
 internal void Cancel()
 {
     if (_operation != null)
     {
         Debug.Assert(_operation.Status == DispatcherOperationStatus.Pending);
         _operation.Abort();
         _operation = null;
     }
 }
Exemple #6
0
        public void Enqueue(object userState)
        {
            if (userState == null)
                throw new ArgumentNullException("userState");

            CurrentContext = userState as BackgroundActionContext;
            if (CurrentContext == null)
                throw new NotSupportedException("Not support non BackgroundActionContext type userState");

            _latestOperation = UIDispatcher.BeginInvoke(() => DoWork(userState), DispatcherPriority.Background);
        }
Exemple #7
0
		public void TestDispatcherOpOnThread ()
		{
			Thread t = new Thread (new ThreadStart (thread));
			Dispatcher d = Dispatcher.CurrentDispatcher;
			
			t.Start ();
			op = Dispatcher.CurrentDispatcher.BeginInvoke (DispatcherPriority.Normal, (Action) delegate {
				Console.WriteLine ("Some methods");
			});
			wait.Set ();
			wait2.WaitOne ();
		}
        internal void Reprioritize(DispatcherOperation op, DispatcherPriority oldpriority)
        {
            int          oldp = (int)oldpriority;
            PokableQueue q    = priority_queues [oldp];

            lock (q)
            {
                q.Remove(op);
            }
            Queue(op.Priority, op);
            hooks.EmitOperationPriorityChanged(op);
        }
        /// <summary>
        ///     Requests that a new DispatcherOperation be placed on the Dispatcher queue
        /// </summary>
        /// <param name="arg">The object to send the callback in its arg parameter.</param>
        internal void Request(object arg)
        {
            if (_operation != null)
            {
                Cancel();
            }

            _operation = Dispatcher.CurrentDispatcher.BeginInvoke(
                DispatcherPriority.Background,
                new DispatcherOperationCallback(DispatcherOperation),
                arg);
        }
        internal void Request(object arg)
        {
            if (_operation == null)
            {
                Debug.Assert(_callback != null);

                _operation =
                    Dispatcher.CurrentDispatcher.BeginInvoke(
                        DispatcherPriority.Loaded,
                        new DispatcherOperationCallback(DispatcherOperation), arg);
            }
        }
Exemple #11
0
        private bool TryDequeue(out DispatcherOperation operation)
        {
            while (disableProcessingRequests == 0 && queue.TryPeek(out operation) && operation.Priority != DispatcherPriority.Inactive)
            {
                queue.Dequeue();

                if (operation.Status != DispatcherOperationStatus.Pending)
                {
                    continue;
                }

                return(true);
            }

            operation = null;
            return(false);
        }
Exemple #12
0
        void Queue(DispatcherPriority priority, DispatcherOperation x)
        {
            int          p = ((int)priority);
            PokableQueue q = priority_queues [p];

            lock (q){
                int flag = 1 << p;
                q.Enqueue(x);
                queue_bits |= flag;
            }
            hooks.EmitOperationPosted(x);

            if (Thread.CurrentThread != base_thread)
            {
                wait.Set();
            }
        }
Exemple #13
0
        private static void PrintOnConsole(string message, object color, DispatcherPriority priority = DispatcherPriority.Background)
        {
            DateTime TimeStamp = DateTime.Now;

            message = $"[{TimeStamp.ToLongTimeString()}] {message}";
            LogString msg = new LogString()
            {
                Text  = message,
                Color = color
            };

            LastOperation = Instance.Dispatcher.BeginInvoke(priority, new Action(() =>
            {
                logs.Add(msg);
                ScrollToEnd();
            }));
        }
        private static void PrintOnConsole(string message, object color, DispatcherPriority priority = DispatcherPriority.Background)
        {
            DateTime TimeStamp = DateTime.Now;

            message       = $"[{TimeStamp.ToLongTimeString()}] {message}\n";
            LastOperation = _Instance.Dispatcher.BeginInvoke(
                priority,
                new Action(() =>
            {
                TextRange msg = new TextRange(_Instance.Console.Document.ContentEnd, _Instance.Console.Document.ContentEnd)
                {
                    Text = message
                };
                msg.ApplyPropertyValue(TextElement.ForegroundProperty, color);
                ScrollToEnd();
            })
                );
        }
        public DispatcherOperation BeginInvoke(DispatcherPriority priority, Delegate method, object arg, params object [] args)
        {
            if (priority < 0 || priority > DispatcherPriority.Send)
            {
                throw new InvalidEnumArgumentException("priority");
            }
            if (priority == DispatcherPriority.Inactive)
            {
                throw new ArgumentException("priority can not be inactive", "priority");
            }
            if (method == null)
            {
                throw new ArgumentNullException("method");
            }

            DispatcherOperation op = new DispatcherOperation(this, priority, method, arg, args);

            Queue(priority, op);

            return(op);
        }
        public object Invoke(DispatcherPriority priority, Delegate method)
        {
            if (priority < 0 || priority > DispatcherPriority.Send)
            {
                throw new InvalidEnumArgumentException("priority");
            }
            if (priority == DispatcherPriority.Inactive)
            {
                throw new ArgumentException("priority can not be inactive", "priority");
            }
            if (method == null)
            {
                throw new ArgumentNullException("method");
            }

            DispatcherOperation op = new DispatcherOperation(this, priority, method);

            Queue(priority, op);
            PushFrame(new DispatcherFrame());

            throw new NotImplementedException();
        }
Exemple #17
0
        private void Invoke(DispatcherOperation operation)
        {
            queue.Enqueue(operation.Priority, operation);

            DispatcherOperation currentOperation;

            while (TryDequeue(out currentOperation))
            {
                currentOperation.Invoke();

                if (currentOperation == operation)
                {
                    return;
                }
            }

            if (disableProcessingRequests > 0)
            {
                throw new Granular.Exception("Can't invoke an operation while the dispatcher processing is disabled");
            }

            throw new Granular.Exception("Can't invoke an inactive or aborted operation");
        }
            public DispatcherOperationEvent(DispatcherOperation op, TimeSpan timeout)
            {
                _operation   = op;
                _timeout     = timeout;
                _event       = new ManualResetEvent(false);
                _eventClosed = false;

                lock (DispatcherLock)
                {
                    // We will set our event once the operation is completed or aborted.
                    _operation.Aborted   += new EventHandler(OnCompletedOrAborted);
                    _operation.Completed += new EventHandler(OnCompletedOrAborted);

                    // Since some other thread is dispatching this operation, it could
                    // have been dispatched while we were setting up the handlers.
                    // We check the state again and set the event ourselves if this
                    // happened.
                    if (_operation._status != DispatcherOperationStatus.Pending && _operation._status != DispatcherOperationStatus.Executing)
                    {
                        _event.Set();
                    }
                }
            }
        /// <summary>
        /// Invalidates the realization state of all items being hosted by this panel. After the invalidation, the panel will have its reality updated, which will occur asynchronously unless subsequently forced by <see cref="UpdateReality"/>. 
        /// </summary>
        public void InvalidateReality()
        {
            if (RealizeOperation != null)
            {
                RealizeOperation.Abort();
            }

            object state = null;
            Action action = null;

            action = delegate
            {
                RealizeOperation = null;
                state = RealizeCore(state);
                if (state != null && RealizeOperation == null)
                {
                    RealizeOperation = Dispatcher.BeginInvoke(action, RealizationPriority);
                }
            };

            RealizeOperation = Dispatcher.BeginInvoke(action, RealizationPriority);
        }
 private object DispatcherOperation(object arg)
 {
     try
     {
         Debug.Assert(_operation != null && _operation.Status == DispatcherOperationStatus.Executing);
         _callback(arg);
     }
     finally
     {
         _operation = null;
     }
     return null;
 }
        static void WindowActivating(object sender, WindowActivateEventArgs e)
        {
            if (Keyboard.FocusedElement == null && 
                _lastFocusedElement != null && 
                _lastFocusedElement.IsAlive)
            {
                var elementToSetFocus = _lastFocusedElement.Target as ILayoutElement;
                if (elementToSetFocus != null)
                {
                    var manager = elementToSetFocus.Root.Manager;
                    if (manager == null)
                        return;

                    IntPtr parentHwnd;
                    if (!manager.GetParentWindowHandle(out parentHwnd))
                        return;

                    if (e.HwndActivating != parentHwnd)
                        return;

                    _setFocusAsyncOperation = Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() =>
                    {
                        try
                        {
                            SetFocusOnLastElement(elementToSetFocus);
                        }
                        finally
                        {
                            _setFocusAsyncOperation = null;
                        }
                    }), DispatcherPriority.Input);
                }
            }
        }
 /// <summary>
 /// Ensures that all items being hosted by this panel are properly realized or virtualized.
 /// </summary>
 public void UpdateReality()
 {
     RealizeOperation.Abort();
     RealizeOperation = null;
     object state = null;
     do
     {
         state = RealizeCore(state);
     }
     while (state != null);
 }
        void CollectLayoutItemsDeleted()
        {
            if (_collectLayoutItemsOperations != null)
                return;
            _collectLayoutItemsOperations = Dispatcher.BeginInvoke(new Action(() =>
                {
                    _collectLayoutItemsOperations = null;
                    foreach (var itemToRemove in _layoutItems.Where(item => item.LayoutElement.Root != Layout).ToArray())
                    {

                        if (itemToRemove != null &&
                            itemToRemove.Model != null &&
                            itemToRemove.Model is UIElement)
                        {
                            //((ILogicalChildrenContainer)this).InternalRemoveLogicalChild(itemToRemove.Model as UIElement);
                        }

                        itemToRemove.Detach();
                        _layoutItems.Remove(itemToRemove);

                    }
                }));
        }
 private void RecordGazePointToList(double x, double y, double ts)
 {
     gazeStream = Dispatcher.BeginInvoke(new SetEyePointDeligate(setPos), x, y, ts);
 }
 public DispatcherOperationTaskMapping(DispatcherOperation operation)
 {
     Operation = operation;
 }
Exemple #26
0
            // Note: we pass "exitWhenRequested=false" to the base
            // DispatcherFrame construsctor because we do not want to exit
            // this frame if the dispatcher is shutting down. This is
            // because we may need to invoke operations during the shutdown process.
            public DispatcherOperationFrame(DispatcherOperation op, TimeSpan timeout) : base(false)
            {
                _operation = op;
                
                // We will exit this frame once the operation is completed or aborted.
                _operation.Aborted += new EventHandler(OnCompletedOrAborted);
                _operation.Completed += new EventHandler(OnCompletedOrAborted);

                // We will exit the frame if the operation is not completed within
                // the requested timeout.
                if(timeout.TotalMilliseconds > 0)
                {
                    _waitTimer = new Timer(new TimerCallback(OnTimeout),
                                           null,
                                           timeout,
                                           TimeSpan.FromMilliseconds(-1));
                }

                // Some other thread could have aborted the operation while we were
                // setting up the handlers.  We check the state again and mark the
                // frame as "should not continue" if this happened.
                if(_operation._status != DispatcherOperationStatus.Pending)
                {
                    Exit();
                }

            }
Exemple #27
0
 private void InvokeAsync(DispatcherOperation operation)
 {
     queue.Enqueue(operation.Priority, operation);
     ProcessQueueAsync();
 }
Exemple #28
0
        bool IWeakEventListener.ReceiveWeakEvent(Type managerType, object sender, EventArgs eventArgs)
        {
            var propertyChangedEventArgs = eventArgs as PropertyChangedEventArgs;
            if (propertyChangedEventArgs == null)
                return false;

            Debug.Assert(propertyChangedEventArgs.PropertyName == nameof(ICommandItem.IsVisible), "Unexpected PropertyChanged event occurred.");

            // Avoid unnecessary updates.
            if (_coerceVisibilityOperation != null && _coerceVisibilityOperation.Status == DispatcherOperationStatus.Pending)
                return true;

            // Do not take action immediately. There could be several visibility changes coming.
            _coerceVisibilityOperation = WindowsHelper.Dispatcher.BeginInvoke(_coerceVisibilityAction);

            return true;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DispatcherOperationProxy"/> class.
 /// </summary>
 /// <param name="operation">The operation.</param>
 public DispatcherOperationProxy(DispatcherOperation operation)
 {
     _operation = operation;
 }
        private static void InvokeInSecurityContext(Object state)
        {
            DispatcherOperation operation = (DispatcherOperation)state;

            operation.InvokeImpl();
        }
 public abstract void Initialize(DispatcherOperation operation);
Exemple #32
0
        /// <summary>
        /// Открыть порт
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_openPort_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (Port != null)
                {
                    bufReader.Abort();
                    recvDispatcher.Abort();
                    Port.Close();
                    Port = null;

                    log_out("Порт закрыт", false);
                    btn_openPort.Content = "Открыть порт";
                }
                else
                {
                    int baudRate;
                    int dataBits = 8;

                    string selectedPort = cb_port.SelectedValue.ToString();
                    string selectedSpeed = (cb_speed.Text ?? "").ToString();

                    if (!int.TryParse(selectedSpeed, out baudRate) || baudRate <= 0)
                        throw new Exception("Введите корректное значение скорости");
                    if (selectedPort == string.Empty)
                        throw new Exception("Выберите порт");

                    Port = new SerialPort(selectedPort, baudRate, Parity.None, dataBits, StopBits.One) { Handshake = System.IO.Ports.Handshake.None };

                    Port.Open();
                    recvDispatcher = Dispatcher.BeginInvoke(recvAction, DispatcherPriority.Background);
                    bufReader.Start();

                    log_in(string.Format("Открыт порт {0}, скорость {1}", selectedPort, baudRate));
                    btn_openPort.Content = "Закрыть порт";
                }
            }
            catch (UnauthorizedAccessException ex)
            {
                log_out(ex.Message, false, false);
                Port = null;
            }
            catch (Exception ex)
            {
                log_out(ex.Message, false, false);
            }
        }
Exemple #33
0
		public DispatcherOperation BeginInvoke (Delegate d, params object[] args)
		{
			DispatcherOperation op = null;
			lock (queuedOperations) {
				op = new DispatcherOperation (d, args);
				queuedOperations.Enqueue (op);
				if (!pending) {
					if (callback == null)
						callback = new TickCallHandler (dispatcher_callback);
					NativeMethods.time_manager_add_dispatcher_call (NativeMethods.surface_get_time_manager (Deployment.Current.Surface.Native),
					                                                   callback, IntPtr.Zero);
					pending = true;
				}
			}
			return op;
		}
 public abstract void Initialize(DispatcherOperation operation);
 /// <summary>
 /// 
 /// </summary>
 public DPFCanvas()
 {
     updateAndRenderAction = UpdateAndRender;
     updateAndRenderOperation = null;
     renderTimer = new Stopwatch();
     MaxRenderingDuration = TimeSpan.FromMilliseconds(20.0);
     Loaded += OnLoaded;
     Unloaded += OnUnloaded;
     ClearColor = global::SharpDX.Color.Gray;
     IsShadowMapEnabled = false;
     IsMSAAEnabled = true;
 }
Exemple #36
0
            public DispatcherOperationEvent(DispatcherOperation op, TimeSpan timeout)
            {
                _operation = op;
                _timeout = timeout;
                _event = new ManualResetEvent(false);
                _eventClosed = false;
                
                lock(DispatcherLock)
                {
                    // We will set our event once the operation is completed or aborted.
                    _operation.Aborted += new EventHandler(OnCompletedOrAborted);
                    _operation.Completed += new EventHandler(OnCompletedOrAborted);

                    // Since some other thread is dispatching this operation, it could
                    // have been dispatched while we were setting up the handlers.
                    // We check the state again and set the event ourselves if this
                    // happened.
                    if(_operation._status != DispatcherOperationStatus.Pending && _operation._status != DispatcherOperationStatus.Executing)
                    {
                        _event.Set();
                    }
                }
            }
        /// <summary>
        /// Handles the <see cref="CompositionTarget.Rendering"/> event.
        /// </summary>
        /// <param name="sender">The sender is in fact a the UI <see cref="Dispatcher"/>.</param>
        /// <param name="e">Is in fact <see cref="RenderingEventArgs"/>.</param>
        private void OnRendering(object sender, EventArgs e)
        {
            if (!renderTimer.IsRunning)
                return;

            // Check if there is a deferred updateAndRenderOperation in progress.
            if (updateAndRenderOperation != null)
            {
                // If the deferred updateAndRenderOperation has not yet ended...
                var status = updateAndRenderOperation.Status;
                if (status == DispatcherOperationStatus.Pending ||
                    status == DispatcherOperationStatus.Executing)
                {
                    // ... return immediately.
                    return;
                }

                updateAndRenderOperation = null;

                // Ensure that at least every other cycle is done at DispatcherPriority.Render.
                // Uncomment if animation stutters, but no need as far as I can see.
                // this.lastRenderingDuration = TimeSpan.Zero;
            }

            // If rendering took too long last time...
            if (lastRenderingDuration > MaxRenderingDuration)
            {
                // ... enqueue an updateAndRenderAction at DispatcherPriority.Input.
                updateAndRenderOperation = Dispatcher.BeginInvoke(
                    updateAndRenderAction, DispatcherPriority.Input);
            }
            else
            {
                UpdateAndRender();
            }
        }
        void OnLayoutRootPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "RootPanel")
            {
                if (IsInitialized)
                {
                    var layoutRootPanel = CreateUIElementForModel(Layout.RootPanel) as LayoutPanelControl;
                    LayoutRootPanel = layoutRootPanel;
                }
            }
            else if (e.PropertyName == "ActiveContent")
            {
                if (Layout.ActiveContent != null)
                {
                    //Debug.WriteLine(new StackTrace().ToString());

                    //set focus on active element only after a layout pass is completed
                    //it's possible that it is not yet visible in the visual tree
                    if (_setFocusAsyncOperation == null)
                    {
                        _setFocusAsyncOperation = Dispatcher.BeginInvoke(new Action(() =>
                            {
                                if (Layout.ActiveContent != null)
                                    FocusElementManager.SetFocusOnLastElement(Layout.ActiveContent);
                                _setFocusAsyncOperation = null;
                            }), DispatcherPriority.Background);
                    }
                }

                if (!_insideInternalSetActiveContent)
                    ActiveContent = Layout.ActiveContent != null ?
                        Layout.ActiveContent.Content : null;
            }
        }
Exemple #39
0
		void UpdateUnread()
		{
			if (_updateUnreadOperation == null && Container != null)
				_updateUnreadOperation = ApplicationService.BeginInvoke(new Action(() =>
				{
					_updateUnreadOperation = null;
					if (Container.IsVisibleLayout)
						_unreadCount = 0;
					var title = GetDefaultTitle();
					Container.Title = _unreadCount == 0 ? title : string.Format("{0} {1}", title, _unreadCount);
				}));
		}
Exemple #40
0
 public DispatcherHookEventArgs(DispatcherOperation operation)
 {
     this.operation = operation;
 }
Exemple #41
0
        /// <summary>
        /// Called when [rendering].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void OnRendering(object sender, EventArgs e)
        {
            if (this.isDirty)
            {
                if (this.LowPriorityRendering)
                {
                    // if we called render previously...
                    if (this.previousRenderCall != null)
                    {
                        var previousStatus = this.previousRenderCall.Status;

                        // ... and the operation didn't finish yet - then skip the current call
                        if (previousStatus == System.Windows.Threading.DispatcherOperationStatus.Pending
                            || previousStatus == System.Windows.Threading.DispatcherOperationStatus.Executing)
                        {
                            return;
                        }
                    }

                    this.previousRenderCall = this.Dispatcher.BeginInvoke(this.renderDelegate, System.Windows.Threading.DispatcherPriority.Input);
                }
                else
                {
                    this.renderDelegate();
                }

                this.IsDirty = this.AutoRender;
            }
        }
Exemple #42
0
		public DispatcherOperation BeginInvoke (Delegate d, params object[] args)
		{
			DispatcherOperation op = null;

			if (Deployment.IsShuttingDown) {
				/* DRT #232: some object calls us from the dtor, which happens to run upon shutdown. Here we access
				 * Deployment::Current::Surface, which may have been destroyed if we're shutting down (and accessing
				 * it again will recreate it, which is very bad). So just bail out if this is the case. */
				return new DispatcherOperation (null, null); // return a dummy object
			}

			lock (queuedOperations) {
				op = new DispatcherOperation (d, args);
				queuedOperations.Enqueue (op);
				if (time_manager == IntPtr.Zero) {
					if (callback == null)
						callback = new TickCallHandler (dispatcher_callback);
					time_manager = NativeMethods.surface_get_time_manager_reffed (Deployment.Current.Surface.Native);
					NativeMethods.time_manager_add_dispatcher_call (time_manager, callback, IntPtr.Zero);
				}
			}
			return op;
		}
 public DispatcherOperationAsyncResult(DispatcherOperation operation)
 {
     operation.ThrowIfNull("operation");
     this._AsyncWaitHandle = new Lazy<WaitHandle>(this.AsyncWaitHandleFactory);
     this.Operation = operation;
 }
Exemple #44
0
        /// <summary>
        /// Parses the current document content
        /// </summary>
        public void Parse()
        {
            IsParsing = true;
            string code = "";

            Dispatcher.Invoke(new Action(() => code = Editor.Text));
            GC.Collect();
            DModule newAst = null;
            //try	{
                SyntaxTree = null;
                using (var sr = new StringReader(code))
                using (var parser = DParser.Create(sr))
                {
                    var sw = new Stopwatch();
                    code = null;

                    sw.Restart();

                    newAst = parser.Parse();

                    sw.Stop();

                    SyntaxTree = newAst;

                    ParseTime = sw.Elapsed.TotalMilliseconds;
                }
            /*}
            catch (Exception ex)
            {
                ErrorLogger.Log(ex, ErrorType.Warning, ErrorOrigin.Parser);
            }*/

            lastSelectedBlock = null;
            lastSelectedStatement = null;

            if (newAst != null)
            {
                newAst.FileName = AbsoluteFilePath;
                newAst.ModuleName = ProposedModuleName;
            }
            //TODO: Make semantic highlighting 1) faster and 2) redraw symbols immediately
            UpdateSemanticHighlighting(true);
            //CanRefreshSemanticHighlightings = false;

            UpdateTypeLookupData();

            if (postParseOperation != null && postParseOperation.Status != DispatcherOperationStatus.Completed)
                postParseOperation.Abort();

            postParseOperation = Dispatcher.BeginInvoke(new Action(() =>
            {
                try
                {
                    if (GlobalProperties.Instance.ShowSpeedInfo)
                        CoreManager.Instance.MainWindow.SecondLeftStatusText =
                            Math.Round((decimal)ParseTime, 3).ToString() + "ms (Parsing duration)";

                    UpdateFoldings();
                    CoreManager.ErrorManagement.RefreshErrorList();
                    RefreshErrorHighlightings();
                }
                catch (Exception ex) { ErrorLogger.Log(ex, ErrorType.Warning, ErrorOrigin.System); }
            }), DispatcherPriority.ApplicationIdle);

            IsParsing = false;
        }
 public DispatcherOperationTaskMapping(DispatcherOperation operation)
 {
     Operation = operation;
 }
Exemple #46
0
        private void work()
        {
            while (!m_disposed) {
            bool getInput = false;

            using (m_lockHelper.GetLock()) {
              if (m_disposed) {
            continue;
              }
              else if (m_workWaiting) {
            getInput = true;
            m_workWaiting = false;
              }
              else {
            m_lockHelper.Wait();
            continue;
              }
            }

            if (getInput && !m_disposed) {

              m_operation = Dispatcher.BeginInvoke(DispatcherPriority.Background, m_preWork);

              if (!m_disposed && m_operation.Wait() == DispatcherOperationStatus.Completed) {
            bool processInput = (bool)m_operation.Result;
            m_operation = null;

            if (processInput) {
              bool workSucceeded = false;
              try {
                m_work();
                workSucceeded = true;
              }
              catch (Exception ex) {
                if (Util.IsCriticalException(ex)) {
                  throw;
                }
                else {
                  OnClientException(new NotifyWorkerClientExceptionEventArgs(ex));
                }
              }

              if (!m_disposed && workSucceeded) {
                // Aside from just calling m_postWork,
                //  we want to call OnClientException with null to clear
                //  out a LastException, if one exists...all on the Dispatcher thread
                m_operation = Dispatcher.BeginInvoke(DispatcherPriority.Background,
                    new Action(delegate() {
                  m_postWork();
                  OnClientException(null);
                }));

                if (!m_disposed) {
                  m_operation.Wait();
                }

                m_operation = null;

              } // if (!m_disposed && workSucceeded)

            } // if (processInput && !m_disposed)

              } // if Operation completed

            } // if (getInput)

              } // while (!m_disposed)
        }
Exemple #47
0
 public void BeginInvoke(DispatcherOperation operation)
 {
     queue.Enqueue(operation.Priority, operation);
     ProcessQueue();
 }