public void Enqueue(CompositeDirective directive) { if (waitForSendDirectives.Count < 500) { waitForSendDirectives.Enqueue(directive); } }
private async Task Init() { while (true) { CompositeDirective temp = null; if (_waitForSendDirectives.TryDequeue(out temp)) { if (temp == null) { await Task.Delay(10); continue; } if (temp.DirectiveType == SimDirectiveType.Location) { await SendCommand(new CengWriteDirective()); var x = await SendCommand(new CengReadDirective()); temp.Handle(x).IgnorCompletion(); } else if (temp.DirectiveType == SimDirectiveType.HttpGet) { var directive = temp as HttpCompositeDirective; if (directive == null) { await Task.Delay(10); continue; } await SendCommand(new CregDirective()); var x = await SendCommand(new HttpBearerQueryDirective()); if (!x.Status) //bearer错误 需要关闭后在打开 { await SendCommand(new HttpBearerCloseDirective()); await SendCommand(new HttpBearerOpenDirective()); } else if (!x.IsExecOk) { await SendCommand(new HttpBearerOpenDirective()); } await SendCommand(new HttpInitDirective()); await SendCommand(new HttpParaUrlDirective(directive.Url)); await SendCommand(new HttpParaCidDirective()); await SendCommand(new HttpActionGetDirective()); var p = await SendCommand(new HttpReadDirective()); await SendCommand(new HttpTermDirective()); temp.Handle(p).IgnorCompletion(); } } await Task.Delay(10); } }
public void Enqueue(CompositeDirective directive) { if (_waitForSendDirectives.Count >= 500) { return; } LogFactory.Create().Info("new directive " + directive.GetType()); _waitForSendDirectives.Enqueue(directive); }