private void WorkerProc(object state) { try { using (var socket = this._ctx.CreateSocket(SocketType.Rep)) { socket.Connect(this._backendEndpoint); var polling = new Polling(PollingEvents.RecvReady, socket); // once data is ready, we pass it along to the actual worker polling.RecvReady += _ => { var msg = socket.Recv(); this._proc(msg, socket); }; while (_running) { polling.PollForever(); } } } catch (ZmqException e) { if (LogAdapter.LogEnabled) { LogAdapter.LogError(this.GetType().FullName, e.ToString()); } if (e.ZmqErrorCode != ZmqErrorCode.ETERM) throw; } }
public void Execute(IJobExecutionContext context) { _logger.InfoFormat("-------------开始------------"); Polling p = new Polling(); p.GetOnce(); _logger.InfoFormat("-------------结束------------"); _logger.InfoFormat("-------------收费开始------------"); p.RePushSF(); _logger.InfoFormat("-------------收费结束------------"); }
/// <summary> /// Asynchronously polls the operation until it is complete, returning the completed operation. /// </summary> /// <remarks> /// If this object already represents a completed operation, it is returned immediately, /// with no further RPCs. /// </remarks> /// <param name="pollSettings">The settings to use for repeated polling, or null /// to use the default poll settings (poll once every 10 seconds, forever).</param> /// <param name="callSettings">The call settings to apply on each call, or null for default settings.</param> /// <returns>The completed operation, which can then be checked for errors or a result.</returns> public Task <Operation <T> > PollUntilCompletedAsync(PollSettings pollSettings = null, CallSettings callSettings = null) { if (IsCompleted) { return(Task.FromResult(this)); } // TODO: Use the deadline. Func <DateTime?, Task <Operation <T> > > pollAction = deadline => PollOnceAsync(callSettings); return(Polling.PollRepeatedlyAsync(pollAction, o => o.IsCompleted, Client.Clock, Client.Scheduler, pollSettings ?? s_defaultPollSettings)); }
public ActionResult Create([Bind(Include = "ID,Name,FormLink")] Polling polling) { if (ModelState.IsValid) { db.Pollings.Add(polling); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(polling)); }
/// <summary> /// Registers the actions. /// </summary> public Input(FishingGame game) : base(game) { Register(Action, Polling.Any(Polling.One(Buttons.A), Polling.One(Buttons.Start))); Register(AltAction, Polling.One(Buttons.B)); Register(Cancel, Polling.Any(Polling.One(Buttons.B), Polling.One(Buttons.Back))); Register(Up, Polling.Any(Polling.One(Buttons.DPadUp), Polling.One(Buttons.LeftThumbstickUp))); Register(Down, Polling.Any(Polling.One(Buttons.DPadDown), Polling.One(Buttons.LeftThumbstickDown))); Register(Start, Polling.One(Buttons.Start)); Register(Buy, Polling.One(Buttons.X)); _instance = this; }
private static void ContinuePoll(Polling polling) { Task.Factory.StartNew(() => { try { polling.PollForever(); } catch { } }); }
public void Dispose_IsStarted_Exception() { var p = new Polling(1000, ct => Task.FromResult(false), Mock.Of <ILogger>()); p.StartPolling(); p.Dispose(); Assert.Throws <ObjectDisposedException>(() => { var _ = p.IsStarted; }); }
public PollingRegistry() { EnableInMemoryTransport(); Polling.RunJob <OneJob>().ScheduledAtInterval <PollingSettings>(x => x.OneInterval); Polling.RunJob <TwoJob>().ScheduledAtInterval <PollingSettings>(x => x.TwoInterval); Polling.RunJob <ThreeJob>().ScheduledAtInterval <PollingSettings>(x => x.ThreeInterval).RunImmediately(); Polling.RunJob <DisabledJob>().ScheduledAtInterval <PollingSettings>(x => x.DisabledInterval).Disabled(); Services(x => x.ReplaceService <IPollingJobLogger, RecordingPollingJobLogger>()); }
// POST: api/ApiPolling public void Post([FromBody] List <Polling> polling) { foreach (Polling item in polling) { item.SubmittedDate = DateTime.Now; Polling p = item; if (ModelState.IsValid) { _pollingRepo.Add(ref p); } } }
public async Task FullyUpdateData() { if (!string.IsNullOrEmpty(User.Identity.Name)) { using (var context = new StructureContext()) { await Polling.FullyUpdateData(context); } } Response.Redirect("/Me/Notifications"); }
/// <summary> /// Update a service's traffic split. /// </summary> private async void UpdateTrafficSplit(TrafficSplit split) { IsLoading = true; Children.Clear(); UpdateContextMenu(); Caption = Resources.CloudExplorerGaeUpdateTrafficSplitMessage; GaeDataSource datasource = root.DataSource.Value; try { Task <Operation> operationTask = root.DataSource.Value.UpdateServiceTrafficSplit(split, Service.Id); Func <Operation, Task <Operation> > fetch = (o) => datasource.GetOperationAsync(o.GetOperationId()); Predicate <Operation> stopPolling = (o) => o.Done ?? false; Operation operation = await Polling <Operation> .Poll(await operationTask, fetch, stopPolling); if (operation.Error != null) { throw new DataSourceException(operation.Error.Message); } Service = await datasource.GetServiceAsync(Service.Id); Caption = Service.Id; EventsReporterWrapper.ReportEvent(GaeTrafficSplitUpdatedEvent.Create(CommandStatus.Success)); } catch (Exception ex) when(ex is DataSourceException || ex is TimeoutException || ex is OperationCanceledException) { EventsReporterWrapper.ReportEvent(GaeTrafficSplitUpdatedEvent.Create(CommandStatus.Failure)); IsError = true; if (ex is DataSourceException) { Caption = Resources.CloudExplorerGaeUpdateTrafficSplitErrorMessage; } else if (ex is TimeoutException) { Caption = Resources.CloudExploreOperationTimeoutMessage; } else if (ex is OperationCanceledException) { Caption = Resources.CloudExploreOperationCanceledMessage; } } finally { IsLoading = false; PresentViewModels(); Icon = s_serviceIcon.Value; UpdateContextMenu(); } }
/// <summary> /// Polls the operation until it is complete, returning the completed operation. /// </summary> /// <remarks> /// If this object already represents a completed operation, it is returned immediately, /// with no further RPCs. /// </remarks> /// <param name="pollSettings">The settings to use for repeated polling, or null /// to use the default poll settings (poll once every 10 seconds, forever).</param> /// <param name="callSettings">The call settings to apply on each call, or null for default settings.</param> /// <returns>The completed operation, which can then be checked for errors or a result.</returns> public Operation <T> PollUntilCompleted(PollSettings pollSettings = null, CallSettings callSettings = null) { if (IsCompleted) { return(this); } // TODO: Use the deadline and get a cancellation token from the effective call settings. Func <DateTime?, Operation <T> > pollAction = deadline => PollOnce(callSettings); return(Polling.PollRepeatedly( pollAction, o => o.IsCompleted, Client.Clock, Client.Scheduler, pollSettings ?? s_defaultPollSettings, CancellationToken.None)); }
private void Update() { if (Input.GetMouseButton(0)) { RaycastHit raycastHit; if (Physics.Raycast(Camera.ScreenPointToRay(Input.mousePosition), out raycastHit)) { var dir = new Vector3(raycastHit.point.x, transform.position.y, raycastHit.point.z); var bullet = Polling.GetObjcet(); //Instantiate(bulletPerfab, transform.position + dir.normalized, Quaternion.identity).GetComponent<PollingBullet>(); bullet.transform.position = transform.position + dir.normalized; bullet.Shot(dir); } } }
/// <summary> /// Asynchronously polls the operation until it is complete, returning the completed operation. /// </summary> /// <remarks> /// If this object already represents a completed operation, it is returned immediately, /// with no further RPCs. /// </remarks> /// <param name="pollSettings">The settings to use for repeated polling, or null /// to use the default poll settings (poll once every 10 seconds, forever).</param> /// <param name="callSettings">The call settings to apply on each call, or null for default settings.</param> /// <returns>The completed operation, which can then be checked for errors or a result.</returns> public Task <Operation <T> > PollUntilCompletedAsync(PollSettings pollSettings = null, CallSettings callSettings = null) { if (IsCompleted) { return(Task.FromResult(this)); } callSettings = Client.GetEffectiveCallSettingsForGetOperation(callSettings); Func <DateTime?, Task <Operation <T> > > pollAction = deadline => PollOnceAsync(callSettings.WithEarlierDeadline(deadline, Client.Clock)); return(Polling.PollRepeatedlyAsync( pollAction, o => o.IsCompleted, Client.Clock, Client.Scheduler, pollSettings ?? s_defaultPollSettings, callSettings?.CancellationToken ?? CancellationToken.None)); }
// GET: Pollings/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Polling polling = db.Pollings.Find(id); if (polling == null) { return(HttpNotFound()); } return(View(polling)); }
/// <summary> /// Deletes 'this' service. /// </summary> private async void DeleteService() { IsLoading = true; Children.Clear(); UpdateContextMenu(); Caption = String.Format(Resources.CloudExplorerGaeServiceDeleteMessage, Service.Id); GaeDataSource datasource = root.DataSource.Value; try { Task <Operation> operationTask = root.DataSource.Value.DeleteServiceAsync(Service.Id); Func <Operation, Task <Operation> > fetch = (o) => datasource.GetOperationAsync(o.GetOperationId()); Predicate <Operation> stopPolling = (o) => o.Done ?? false; Operation operation = await Polling <Operation> .Poll(await operationTask, fetch, stopPolling); if (operation.Error != null) { throw new DataSourceException(operation.Error.Message); } EventsReporterWrapper.ReportEvent(GaeServiceDeletedEvent.Create(CommandStatus.Success)); } catch (Exception ex) when(ex is DataSourceException || ex is TimeoutException || ex is OperationCanceledException) { EventsReporterWrapper.ReportEvent(GaeServiceDeletedEvent.Create(CommandStatus.Failure)); IsError = true; if (ex is DataSourceException) { Caption = Resources.CloudExplorerGaeDeleteServiceErrorMessage; } else if (ex is TimeoutException) { Caption = Resources.CloudExploreOperationTimeoutMessage; } else if (ex is OperationCanceledException) { Caption = Resources.CloudExploreOperationCanceledMessage; } } finally { IsLoading = false; if (!IsError) { // Remove the deleted child. _owner.Children.Remove(this); } } }
public BuiltInPollingJobRegistry() { Handlers.DisableDefaultHandlerSource(); Polling.RunJob <DelayedEnvelopeProcessor>() .ScheduledAtInterval <TransportSettings>(x => x.DelayMessagePolling); Polling.RunJob <ExpiringListenerCleanup>() .ScheduledAtInterval <TransportSettings>(x => x.ListenerCleanupPolling); Polling.RunJob <HealthMonitorPollingJob>() .ScheduledAtInterval <HealthMonitoringSettings>(x => x.Interval); Polling.RunJob <SubscriptionRefreshJob>() .ScheduledAtInterval <TransportSettings>(x => x.SubscriptionRefreshPolling); }
public async Task TestCollection(string collectionName) { using (var app = StartTestApp(debugEnabled: true)) { var debuggee = Polling.GetDebuggee(app.Module, app.Version); var breakpoint = SetBreakpointAndSleep(debuggee.Id, TestApplication.MainClass, TestApplication.EchoBottomLine); string collectionKey = "RandomKey"; using (HttpClient client = new HttpClient()) { await client.GetAsync($"{app.AppUrlEcho}/{collectionKey}"); } var newBp = Polling.GetBreakpoint(debuggee.Id, breakpoint.Id); // Check that the breakpoint has been hit. Assert.True(newBp.IsFinalState); // Checks that the first frame of the breakpoint contains collection. DebuggerVariable collection = newBp.StackFrames[0].Locals.FirstOrDefault(localVar => localVar.Name == $"test{collectionName}"); Assert.NotNull(collection); Assert.Equal(6, collection.Members.Count); DebuggerVariable collectionCount = collection.Members.FirstOrDefault(member => member.Name == "Count"); Assert.NotNull(collectionCount); Assert.Equal("5", collectionCount.Value); for (int i = 0; i < 5; i += 1) { DebuggerVariable item = collection.Members.FirstOrDefault(member => member.Name == $"[{i}]"); Assert.NotNull(item); if (collectionName == "Dictionary") { DebuggerVariable key = item.Members.FirstOrDefault(member => member.Name == "key"); DebuggerVariable value = item.Members.FirstOrDefault(member => member.Name == "value"); Assert.NotNull(key); Assert.NotNull(value); Assert.Equal($"Key{collectionKey}{i}", key.Value); Assert.Equal($"{i}", value.Value); } else { Assert.Equal($"{collectionName}{collectionKey}{i}", item.Value); } } } }
public void Uri() { var options = new Transport.Options { Path = "/engine.io", Hostname = Connection.CreateOptions().Hostname, Secure = false, Query = new Dictionary <string, string> { { "sid", "test" } }, TimestampRequests = false }; var polling = new Polling(options); var expected = string.Format("http://{0}/engine.io?sid=test&b64=1", options.Hostname); Assert.Contains(expected, polling.Uri()); }
public async Task GetNotifications(int Id) { if (!string.IsNullOrEmpty(User.Identity.Name)) { using (var context = new StructureContext()) { var character = context.Characters.Where(c => c.Id == Id) .FirstOrDefault(); if (character != null) { await Polling.UpdateOneCharacter(context, character); } } } Response.Redirect("/Me/Notifications"); }
/// <inheritdoc/> public bool StartProcessing() { if (_subscribePolling != null && _subscribePolling.IsStarted) { return(false); } if (_serviceHealthDependent) { _healthCheckingService.DiagnosticPassedEvent += OnDiagnosticPassed; _healthCheckingService.DiagnosticFailedEvent += OnDiagnosticFailed; } _subscribePolling = new Polling(_subscribeInterval, ListenMessagesAsync, _logger); _subscribePolling.StartPolling(); return(_subscribePolling.IsStarted); }
public async Task MultipleBreakpointsHit_Wait() { using (var app = StartTestApp(debugEnabled: true)) { var debuggee = Polling.GetDebuggee(app.Module, app.Version); var breakpoint1 = SetBreakpoint(debuggee.Id, TestApplication.MainClass, TestApplication.HelloLine); var breakpoint2 = SetBreakpoint(debuggee.Id, TestApplication.MainClass, TestApplication.EchoTopLine); // Let the first two breakpoints get picked up by the server before // setting the last one. Thread.Sleep(TimeSpan.FromSeconds(5)); var breakpoint3 = SetBreakpoint(debuggee.Id, TestApplication.MainClass, TestApplication.PidLine); // Sleep for long period to ensure multiple get calls to the Debugger API. Thread.Sleep(_hangingGetTimeout); using (HttpClient client = new HttpClient()) { await client.GetAsync(app.AppUrlBase); } var newBp1 = Polling.GetBreakpoint(debuggee.Id, breakpoint1.Id); Assert.True(newBp1.IsFinalState); // Ensure these breakpoints aren't final. var newBp2 = Polling.GetBreakpoint(debuggee.Id, breakpoint2.Id, isFinal: false); var newBp3 = Polling.GetBreakpoint(debuggee.Id, breakpoint3.Id, isFinal: false); Assert.False(newBp2.IsFinalState); Assert.False(newBp3.IsFinalState); // Sleep for long period to ensure multiple get calls to the Debugger API. Thread.Sleep(_hangingGetTimeout); using (HttpClient client = new HttpClient()) { await client.GetAsync($"{app.AppUrlEcho}/1"); await client.GetAsync(app.AppUrlProcessId); } newBp2 = Polling.GetBreakpoint(debuggee.Id, breakpoint2.Id); newBp3 = Polling.GetBreakpoint(debuggee.Id, breakpoint3.Id); Assert.True(newBp2.IsFinalState); Assert.True(newBp3.IsFinalState); } }
/// <inheritdoc/> public void Stop() { try { if (_serviceHealthDependent) { _healthCheckingService.DiagnosticFailedEvent -= OnDiagnosticFailed; _healthCheckingService.DiagnosticPassedEvent -= OnDiagnosticPassed; } _subscribePolling?.Dispose(); _subscribePolling = null; } finally { _adapter.Disconnect(); } }
public async Task BreakpointHit() { using (var app = StartTestApp(debugEnabled: true)) { var debuggee = Polling.GetDebuggee(app.Module, app.Version); var breakpoint = SetBreakpointAndSleep(debuggee.Id, TestApplication.MainClass, TestApplication.HelloLine); using (HttpClient client = new HttpClient()) { await client.GetAsync(app.AppUrlBase); } var newBp = Polling.GetBreakpoint(debuggee.Id, breakpoint.Id); // Check that the breakpoint has been hit. Assert.True(newBp.IsFinalState); } }
/// <inheritdoc /> public void Stop() { try { if (_serviceHealthDependent) { _healthCheckingService.DiagnosticFailedEvent -= OnDiagnosticFailed; _healthCheckingService.DiagnosticPassedEvent -= OnDiagnosticPassed; } _reconnectPolling.Dispose(); _reconnectPolling = null; } finally { Unsubscribe(); } }
private void ExecutePollerTasks() { Action action; var doneSomething = false; while (_pollerTasks.TryDequeue(out action)) { action(); doneSomething = true; } if (!doneSomething) { return; } if (_sockets.Count > 0) { // rebuild poller _polling = new Polling(PollingEvents.SendReady | PollingEvents.RecvReady, _sockets.Keys.ToArray()); _polling.SendReady += s => { //Console.WriteLine("Send ready"); CastleZmqSocket socket; if (_sockets.TryGetValue(s, out socket)) { socket.SendReady(); } }; _polling.RecvReady += s => { //Console.WriteLine("Recv ready"); CastleZmqSocket socket; if (_sockets.TryGetValue(s, out socket)) { socket.ReceiveReady(); } }; } else { _polling = null; } }
public async Task BreakpointHit_AsyncCondition() { string testString = "TestMessage"; string firstCondition = $"PublicString == \"{new TestApp.MainController().PublicString}\""; string secondCondition = "Hello() == \"Hello, World!\""; string thirdCondition = $"testString == \"{testString}\""; using (var app = StartTestApp(debugEnabled: true, methodEvaluation: true)) { Debuggee debuggee = Polling.GetDebuggee(app.Module, app.Version); DebuggerBreakpoint firstBreakpoint = SetBreakpointAndSleep( debuggee.Id, TestApplication.MainClass, TestApplication.AsyncBottomLine, firstCondition); DebuggerBreakpoint secondBreakpoint = SetBreakpointAndSleep( debuggee.Id, TestApplication.MainClass, TestApplication.AsyncBottomLine, secondCondition); DebuggerBreakpoint thirdBreakpoint = SetBreakpointAndSleep( debuggee.Id, TestApplication.MainClass, TestApplication.AsyncBottomLine, thirdCondition); using (HttpClient client = new HttpClient()) { await client.GetAsync($"{app.AppUrlAsync}/{testString}"); } DebuggerBreakpoint retrievedFirstBp = Polling.GetBreakpoint(debuggee.Id, firstBreakpoint.Id); DebuggerBreakpoint retrievedSecondBp = Polling.GetBreakpoint(debuggee.Id, secondBreakpoint.Id); DebuggerBreakpoint retrievedThirdBp = Polling.GetBreakpoint(debuggee.Id, thirdBreakpoint.Id); // Check that the breakpoints has been hit. Assert.True(retrievedFirstBp.IsFinalState); Assert.Null(retrievedFirstBp.Status); Assert.True(retrievedSecondBp.IsFinalState); Assert.Null(retrievedSecondBp.Status); Assert.True(retrievedThirdBp.IsFinalState); Assert.Null(retrievedThirdBp.Status); } }
private Tuple <T, bool> SendReqAndWaitReply(IZmqSocket socket) { SendRequest(socket); var polling = new Polling(PollingEvents.RecvReady, socket); if (polling.Poll(this.Timeout)) { var data = socket.Recv(); var ret = GetReply(data, socket, false); return(Tuple.Create(ret, false)); } else { // timeout var ret = GetReply(null, socket, true); return(Tuple.Create(ret, true)); } }
public ActionResult RePush(string slbh) { try { WriteBackWfm wfm = WriteBackWfm.GetInstance(); Polling p = new Polling(); string area = ConfigurationManager.AppSettings["Area"].ToString(); var rt = p.PushASLBH(slbh, wfm, area); object ro = new { PushRet = rt.IsSuccess, SLBH = slbh, Message = rt.Message }; return(Json(ro)); } catch (Exception ex) { #if DEBUG throw new Exception(ex.Message); #else throw new Exception(ex.Message); #endif } }
public void Uri() { var log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod()); log.Info("Start"); var options = new Transport.Options(); options.Path = "/engine.io"; options.Hostname = this.CreateOptions().Hostname; options.Secure = false; options.Query = new Dictionary <string, string> { { "sid", "test" } }; options.TimestampRequests = false; var polling = new Polling(options); var expected = string.Format("http://{0}/engine.io?sid=test&b64=1", options.Hostname); Assert.Contains(expected, polling.Uri()); }
public async Task BreakpointHit_Wait() { using (var app = StartTestApp(debugEnabled: true)) { var debuggee = Polling.GetDebuggee(app.Module, app.Version); var breakpoint = SetBreakpointAndSleep(debuggee.Id, TestApplication.MainClass, TestApplication.HelloLine); // Sleep for long period to ensure multiple get calls to the Debugger API. Thread.Sleep(_hangingGetTimeout); using (HttpClient client = new HttpClient()) { await client.GetAsync(app.AppUrlBase); } var newBp = Polling.GetBreakpoint(debuggee.Id, breakpoint.Id); // Check that the breakpoint has been hit. Assert.True(newBp.IsFinalState); } }
public void poll_in_for_req_rep() { using (var repSocket = base.Context.CreateSocket(SocketType.Rep)) using (var reqSocket = base.Context.CreateSocket(SocketType.Req)) { repSocket.Bind("tcp://0.0.0.0:90001"); var polling = new Polling(PollingEvents.RecvReady, repSocket, reqSocket); var rcEvCalled = false; polling.RecvReady += (socket) => { rcEvCalled = true; }; reqSocket.Connect("tcp://127.0.0.1:90001"); reqSocket.Send("Hello"); polling.PollForever(); Assert.IsTrue(rcEvCalled); } }