Beispiel #1
0
        public void init( Process process, DoneEvent done )
        {
            process.bind(done);

            // use delegate
            process.doneEvent += new FeaturedProgressHandler(this.occured);
        }
Beispiel #2
0
 protected override void CheckRepeat()
 {
     if (Done)
     {
         DoneEvent?.Invoke(this, End);
     }
     base.CheckRepeat();
 }
        public void EnqueueDoneEvent(StatenodeId statenodeId)
        {
            var @event = new DoneEvent(statenodeId);

            if (!_queue.Any(queuedEvent => queuedEvent.Match(_ => false, current => current.Event.Equals(@event), _ => false)))
            {
                Enqueue(new CurrentStep(@event));
            }
        }
Beispiel #4
0
            // Method called and passed to user work item queue
            public void ThreadPoolCallback(Object threadContext)
            {
                HttpResponseMessage logResponse;
                string request;
                string content = null;

                // foreach url in the JArray make an http request
                foreach (var rec in Records)
                {
                    try
                    {
                        // pull actual url from object in JArray
                        request = String.Format(CultureInfo.InvariantCulture, rec.Value <string>("contentUri"));

                        // pass request to HttpGet method
                        logResponse = HttpGet(request, AuthResult);

                        // if response is not null read body as string
                        // then write to file specified using the one instance of Writer from the LogPull class
                        if (logResponse != null)
                        {
                            content = logResponse.Content.ReadAsStringAsync().Result;

                            if (content != null)
                            {
                                SafeWriter.WriteToFile(JArray.Parse(content), threadContext.ToString());
                            }
                            else
                            {
                                Console.WriteLine("Error: Null response in thread");
                            }
                        }
                    }
                    catch
                    {
                        // Just to not crash
                        //Debug.WriteLine("Error when making request to content uri");
                    }
                }
                // Write that thread has finished and then set ManualReset Event
                // We write that it has finished to double check all threads finished later on
                Console.WriteLine("Thread {0} Done", threadContext);
                DoneEvent.Set();
            }
Beispiel #5
0
        protected async Task WorkLoop(
            CancellationToken cancellationToken,
            PauseToken pauseToken,
            Action action)
        {
            try
            {
                Running = true;

                while (!cancellationToken.IsCancellationRequested)
                {
                    if (cancellationToken.IsCancellationRequested)
                    {
                        break;
                    }

                    // if pause token, spin here
                    if (pauseToken.IsPaused)
                    {
                        if (PauseHolder(cancellationToken, pauseToken))
                        {
                            break;
                        }
                    }

                    action();
                }
            }
            catch (ThreadAbortException e)
            {
            }
            finally
            {
                Running = false;
                DoneEvent.Set();
            }
        }
Beispiel #6
0
        /// <summary>
        /// Start the device in the current thread. Should be used by implementations of the <see cref="DeviceRunner.Start"/> method.
        /// </summary>
        /// <remarks>
        /// Initializes the sockets prior to starting the device with <see cref="Initialize"/>.
        /// </remarks>
        protected internal void Run()
        {
            EnsureNotDisposed();

            Initialize();

            FrontendSocket.ReceiveReady += (sender, args) => FrontendHandler(args);
            BackendSocket.ReceiveReady  += (sender, args) => BackendHandler(args);

            DoneEvent.Reset();
            IsRunning = true;

            _poller.ClearSockets();
            _poller.AddSockets(new[] { FrontendSocket, BackendSocket });

            TimeSpan timeout = TimeSpan.FromMilliseconds(PollingIntervalMsec);

            try
            {
                while (IsRunning)
                {
                    _poller.Poll(timeout);
                }
            }
            catch (ZmqException)
            {
                // Swallow any exceptions thrown while stopping
                if (IsRunning)
                {
                    throw;
                }
            }

            IsRunning = false;
            DoneEvent.Set();
        }
 public void ThreadPoolCallback(object threadContext)
 {
     FibOfN = Calculate(N);
     DoneEvent.Set();
 }
Beispiel #8
0
 public override void GotoEnd()
 {
     DoneEvent?.Invoke(this, End);
     base.GotoEnd();
 }
Beispiel #9
0
 public void RaiseDoneEvent()
 {
     DoneEvent?.Invoke(this, EventArgs.Empty);
 }
 // Wrapper method for use with thread pool.
 public void ThreadPoolCallback(ref MorphemeAssetProcessor.Result result)
 {
     Process(ref result);
     DoneEvent.Set();
 }
Beispiel #11
0
 internal bool OnDone(T value)
 {
     DoneEvent?.Invoke(value);
     OnAlways();
     return(DoneEvent != null);
 }
Beispiel #12
0
 remove => RemoveHandler(DoneEvent, value);
Beispiel #13
0
 add => AddHandler(DoneEvent, value);
Beispiel #14
0
 private void Handle(DoneEvent e)
 {
     Done = true;
 }
Beispiel #15
0
 public void unBind(DoneEvent done)
 {
     this.dones.Remove(done);
 }
Beispiel #16
0
 public void bind(DoneEvent done)
 {
     this.dones.Add(done);
 }