Ejemplo n.º 1
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="Solution" /> struct.
 /// </summary>
 /// <param name="success">if set to <c>true</c> [Success].</param>
 /// <param name="value">The value.</param>
 /// <param name="iterations">The iterations.</param>
 /// <param name="stopReasons">The stop reasons.</param>
 public Solution(bool success, double value, int iterations, StopReasons stopReasons) : this()
 {
     Success     = success;
     Result      = value;
     Iterations  = iterations;
     StopReasons = stopReasons;
 }
 static void StreamStopped(StopReasons reason)
 {
     if (!jsonView)
     {
         Console.WriteLine(string.Format("The stream has stopped. Reason: {0}", reason.ToString()));
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 ///   Called when the stream is stopped.
 /// </summary>
 /// <param name = "reason">The reason.</param>
 /// <remarks>
 /// </remarks>
 private void OnStreamStopped(StopReasons reason)
 {
     if (streamStoppedCallback != null)
     {
         streamStoppedCallback(reason);
     }
 }
Ejemplo n.º 4
0
 void StreamStopped(StopReasons reason)
 {
     if (reason == StopReasons.StoppedByRequest)
     {
         //Do something...
     }
     else
     {
         //Do something...
     }
 }
 void StreamStopped(StopReasons reason)
 {
     if (reason == StopReasons.StoppedByRequest)
     {
         this._repository.Clear();
         this._stopSearch = true;
     }
     else
     {
         //Do something...
     }
 }
Ejemplo n.º 6
0
        void OnStreamStopped(StopReasons reason)
        {
            Trace.Call(reason);

            try {
                Session.DisableChat(Chat);
            } catch (Exception ex) {
#if LOG4NET
                Logger.Error("OnStreamStopped()", ex);
#endif
            }
        }
Ejemplo n.º 7
0
            public bool ShouldStop(int currentStep, double currentDeltaX, double currentY, DateTime utcStartTime,
                                   out StopReasons stopReasons)
            {
                if (currentY == 0.0)
                {
                    stopReasons = StopReasons.SolutionFound;
                    return(true);
                }

                if (DeltaY.HasValue && Math.Abs(currentY) <= DeltaY.Value)
                {
                    stopReasons = StopReasons.SolutionFound | StopReasons.DeltaY;
                    return(true);
                }

                if (DeltaX.HasValue && Math.Abs(currentDeltaX) <= DeltaX.Value)
                {
                    stopReasons = StopReasons.SolutionFound | StopReasons.DeltaX;
                    return(true);
                }

                if (MaximumNumberOfSteps.HasValue && MaximumNumberOfSteps.Value < currentStep)
                {
                    stopReasons = StopReasons.MaximumNumberOfSteps;
                    return(true);
                }

                if (Timeout.HasValue)
                {
                    var elapsed = DateTime.UtcNow - utcStartTime;
                    if (elapsed > Timeout.Value)
                    {
                        stopReasons = StopReasons.Timeout;
                        return(true);
                    }
                }

                stopReasons = StopReasons.None;
                return(false);
            }
Ejemplo n.º 8
0
 public void EndStream(StopReasons reason, string description)
 {
     this.stopReceived = true;
 }
Ejemplo n.º 9
0
 private void Stop(StopReasons reasons)
 {
 }
 void StreamStopped(StopReasons reason)
 {
     if (reason == StopReasons.StoppedByRequest)
     {
         this._repository.Clear();
         this._stopSearch = true;
     }
     else
     {
         //Do something...
     }
 }
 private void Stopped(StopReasons stopreason)
 {
 }
 /// <summary>
 /// If the stream stopped pushing content
 /// </summary>
 /// <param name="reason"></param>
 /// <remarks>Example override: string message = string.Format("The stream has stopped. Reason: {0}", reason.ToString();</remarks>
 public virtual void StreamStopped(StopReasons reason)
 {
     string message = string.Format("The stream has stopped. Reason: {0}", reason.ToString());
 }
Ejemplo n.º 13
0
 internal void OnStreamError(StopReasons reasons)
 {
     if (StreamError != null) {
         StreamError(reasons);
     }
 }
Ejemplo n.º 14
0
 public void EndStream(StopReasons reason, string description)
 {
     OnStreamingStopped(reason, description);
     this.stopReceived = true;
 }
 private void Stopped(StopReasons stopreason)
 {
 }
Ejemplo n.º 16
0
 static void StreamStopped(StopReasons reason)
 {
     if (!jsonView)
         Console.WriteLine(string.Format("Stream 1 has stopped. Reason: {0}", reason.ToString()));
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Called when the stream is stopped.
 /// </summary>
 /// <param name="reason">The reason.</param>
 /// <remarks></remarks>
 private void OnStreamStopped(StopReasons reason)
 {
     if (this.streamStoppedCallback != null)
         this.streamStoppedCallback(reason);
 }
Ejemplo n.º 18
0
 public static void StreamStopped(StopReasons reason)
 {
     Console.WriteLine(string.Format("The stream has stopped. Reason: {0}", reason.ToString()));
     IfStreamEnabled = false;
 }
 static void StreamStopped(StopReasons reason)
 {
     Trace.WriteLine(string.Format("The stream has stopped. Reason: {0}", reason.ToString()), "Error");
 }
Ejemplo n.º 20
0
 public void EndStream(StopReasons reason, string description)
 {
     this.stopReceived = true;
 }
Ejemplo n.º 21
0
        void OnStreamStopped(StopReasons reason)
        {
            Trace.Call(reason);

            try {
                Session.DisableChat(Chat);
            } catch (Exception ex) {
            #if LOG4NET
                Logger.Error("OnStreamStopped()", ex);
            #endif
            }
        }
Ejemplo n.º 22
0
 internal void StreamStopped(StopReasons stopreason)
 {
     this.Stopped = true;
       this.StopReason = new StopReasons?(stopreason);
       if (App.AppState.Accounts[this.TwitterAccountID].IsSignedIn && stopreason == StopReasons.Unauthorised)
       {
     System.Windows.Application.Current.Dispatcher.Invoke((Action) (() =>
     {
       SimpleErrorPrompt local_0 = new SimpleErrorPrompt()
       {
     DataContext = (object) new
     {
       ErrorHeading = "service halted",
       ErrorText = "The Twitter streaming connection could not start.\r\nPlease ensure your computer time and timezone are accurate before restarting MetroTwit."
     }
       };
       Messenger.Default.Send<PromptMessage>(new PromptMessage()
       {
     IsModal = false,
     PromptView = (FrameworkElement) local_0,
     IsCentered = false
       }, (object) ViewModelMessages.ShowSlidePrompt);
     }));
     this.retrycount = new int?(0);
       }
       else
       {
     StopReasons? nullable1 = this.StopReason;
     if ((nullable1.GetValueOrDefault() != StopReasons.WebConnectionFailed ? 0 : (nullable1.HasValue ? 1 : 0)) != 0 && !this.retrycount.HasValue)
     {
       this.retrycount = new int?(0);
       this.Stream.StartUserStream(new InitUserStreamCallback(this.FriendsReceived), new StreamStoppedCallback(this.StreamStopped), new StatusCreatedCallback(this.StatusReceived), new StatusDeletedCallback(this.StatusDeleted), new DirectMessageCreatedCallback(this.DirectMessageReceived), new DirectMessageDeletedCallback(this.DirectMessageDeleted), new EventCallback(this.EventReceived), (RawJsonCallback) null);
     }
     else
     {
       if (stopreason == StopReasons.StoppedByRequest)
     return;
       if (this.retrytimer == null)
       {
     this.retrytimer = new Timer();
     this.retrytimer.Elapsed += new ElapsedEventHandler(this.retrytimer_Elapsed);
     this.retrytimer.AutoReset = false;
       }
       if (!this.retrycount.HasValue)
     this.retrycount = new int?(0);
       TwitterStreaming twitterStreaming = this;
       int? nullable2 = twitterStreaming.retrycount;
       int? nullable3 = nullable2.HasValue ? new int?(nullable2.GetValueOrDefault() + 1) : new int?();
       twitterStreaming.retrycount = nullable3;
       this.retrytimer.Interval = (double) this.retrycount.Value * TimeSpan.FromSeconds(30.0).TotalMilliseconds;
       if (this.retrytimer.Interval < (stopreason == StopReasons.RateLimited ? TimeSpan.FromMinutes(15.0).TotalMilliseconds : TimeSpan.FromMinutes(5.0).TotalMilliseconds))
     this.retrytimer.Start();
       else
     System.Windows.Application.Current.Dispatcher.Invoke((Action) (() =>
     {
       SimpleErrorPrompt local_0 = new SimpleErrorPrompt()
       {
         DataContext = (object) new
         {
           ErrorHeading = "service disrupted",
           ErrorText = "The Twitter streaming connection has been lost. We've tried reconnecting without success.\r\nTwitter restricts the number of streaming connections you can have at any one time, so please check if you have other Twitter applications running."
         }
       };
       Messenger.Default.Send<PromptMessage>(new PromptMessage()
       {
         IsModal = false,
         PromptView = (FrameworkElement) local_0,
         IsCentered = false
       }, (object) ViewModelMessages.ShowSlidePrompt);
     }));
     }
       }
 }