public async virtual Task StopStream() { Device.RxUart -= DataRecieved; await SendStopCommand(); TCS.SetResult(0); }
public void Cancel() { if (!TCS.TrySetCanceled()) { TCS.Task.Result.Dispose(); } }
public void Cancel() { Device.RxUart -= DataRecieved; TimeoutTimer.Stop(); TimeoutTimer.Dispose(); TCS.SetCanceled(); }
private void ErrorCommand() { Device.RxUart -= DataRecieved; TimeoutTimer.Stop(); TimeoutTimer.Dispose(); TCS.SetException(new CommandFailedException(Data.ToArray())); }
private void bindGrid(Object sender, CommandEventArgs e) { string dept = e.CommandArgument.ToString(); if (dept == "100") { PTTB.Visible = true; PTT.Visible = false; GC.Visible = false; CS.Visible = false; TCS.Visible = false; PTTB.BindPPLDetail(); } else if (dept == "200") { PTTB.Visible = false; PTT.Visible = true; GC.Visible = false; CS.Visible = false; TCS.Visible = false; PTT.BindPPLDetail(); } else if (dept == "300") { PTTB.Visible = false; PTT.Visible = false; GC.Visible = true; CS.Visible = false; TCS.Visible = false; GC.BindPPLDetail(); } else if (dept == "400") { PTTB.Visible = false; PTT.Visible = false; GC.Visible = false; CS.Visible = true; TCS.Visible = false; CS.BindPPLDetail(); } else if (dept == "500") { PTTB.Visible = false; PTT.Visible = false; GC.Visible = false; CS.Visible = false; TCS.Visible = true; TCS.BindPPLDetail(); } else if (dept == "600") { PTTB.Visible = false; PTT.Visible = false; GC.Visible = false; CS.Visible = false; TCS.Visible = false; } }
internal void ReleaseLog() { if (TCS != null && !TCS.Task.IsCompleted) { TCS.SetResult(true); } if (WsTcs != null && !WsTcs.Task.IsCompleted) { WsTcs.SetResult(true); } }
public async Task Execute() { Device.RxUart += DataRecieved; try { await SendStartCommand(); } catch (Exception e) { TCS.SetException(new CommandFailedException(e)); } await TCS.Task; }
private void CompleteCommand() { Device.RxUart -= DataRecieved; TimeoutTimer.Stop(); TimeoutTimer.Dispose(); try { var result = ProcessResult(); TCS.SetResult(result); } catch (Exception e) { TCS.SetException(new CommandFailedException(Data.ToArray(), e)); } }
public override System.Threading.Tasks.Task <Response> Execute(IBillingService service) { this.TCS = new System.Threading.Tasks.TaskCompletionSource <Response>(); if (this.ItemType == Consts.ITEM_TYPE_SUBS && !service.SubscriptionsSupported) { TCS.SetResult(new Response(Consts.SUBSCRIPTIONS_NOT_AVAILABLE)); return(TCS.Task); } try { var buyIntentBundle = service.InAppService.GetBuyIntent(3, service.MainContext.PackageName, this.Sku, this.ItemType, this.ExtraData); int response = Utils.GetResponseCodeFromBundle(buyIntentBundle); if (response != Consts.BILLING_RESPONSE_RESULT_OK) { Utils.LogError("Unable to buy the item, Error response: " + Utils.GetResponseDesc(response)); TCS.SetResult(new Response(response)); return(TCS.Task); } var pendingIntent = buyIntentBundle.GetParcelable(Consts.RESPONSE_BUY_INTENT) as PendingIntent; Utils.LogDebug("Launching buy intent for " + this.Sku + ". Request code: " + this.Id); service.MainActivity.StartIntentSenderForResult(pendingIntent.IntentSender, this.Id, new Intent(), 0, 0, 0); } catch (Android.Content.IntentSender.SendIntentException e) { Utils.LogError(string.Format("SendIntentException while purchasing sku: {0}, message: {1}", this.Sku, e.Message)); TCS.SetResult(new Response(Consts.SEND_INTENT_FAILED, e)); } catch (RemoteException e) { Utils.LogError(string.Format("RemoteException while purchasing sku: {0}, message: {1}", this.Sku, e.Message)); TCS.SetResult(new Response(Consts.REMOTE_EXCEPTION, e)); } catch (System.Exception e) { Utils.LogError(string.Format("Exception while purchasing sku: {0}, message: {1}", this.Sku, e.Message)); this.TCS.SetResult(new Response(Consts.ERROR_BASE, e)); } return(this.TCS.Task); }
public override System.Threading.Tasks.Task <Response> Execute(IBillingService service) { this.TCS = new System.Threading.Tasks.TaskCompletionSource <Response>(); try { if (string.IsNullOrEmpty(this.Item.Token)) { this.TCS.SetResult(new Response(Consts.MISSING_TOKEN)); return(this.TCS.Task); } Utils.LogDebug(string.Format("Consuming sku: {0}, token: {1}", this.Item.Sku, this.Item.Token)); int response = service.InAppService.ConsumePurchase(3, service.MainContext.PackageName, this.Item.Token); if (response == Consts.BILLING_RESPONSE_RESULT_OK) { Utils.LogDebug(string.Format("Successfully consumed sku: {0}, token: {1}", this.Item.Sku, this.Item.Token)); this.TCS.SetResult(new Response()); } else { Utils.LogError(string.Format("Error consuming consuming sku: {0}, token: {1}, message: {2}", this.Item.Sku, this.Item.Token, Utils.GetResponseDesc(response))); this.TCS.SetResult(new Response(response)); } } catch (RemoteException e) { Utils.LogError(string.Format("RemoteException while consuming sku: {0}, token: {1}, message: {2}", this.Item.Sku, this.Item.Token, e.Message)); TCS.SetResult(new Response(Consts.REMOTE_EXCEPTION, e)); } catch (System.Exception e) { Utils.LogError(string.Format("Exception while consuming sku: {0}, token: {1}, message: {2}", this.Item.Sku, this.Item.Token, e.Message)); this.TCS.SetResult(new Response(Consts.ERROR_BASE, e)); } return(this.TCS.Task); }
private void BindGridDetail(string group_id, int level) { string group = group_id.Substring(0, 1); CountPPL.Text = ""; if (group == "1") { PTTB.BindGroupDetail(group_id, level); PTTBPPL.BindPPLDetail(group_id, level); CountPPL.Text = PTTBPPL.CountPPL(); PTTB.Visible = true; PTT.Visible = false; GC.Visible = false; CS.Visible = false; TCS.Visible = false; TEST.Visible = false; PTTPPL.Visible = false; PTTBPPL.Visible = true; GCPPL.Visible = false; CSPPL.Visible = false; TCSPPL.Visible = false; TESTPPL.Visible = false; } else if (group == "2") { PTT.BindGroupDetail(group_id, level); PTTPPL.BindPPLDetail(group_id, level); CountPPL.Text = PTTPPL.CountPPL(); PTTB.Visible = false; PTT.Visible = true; GC.Visible = false; CS.Visible = false; TCS.Visible = false; TEST.Visible = false; PTTPPL.Visible = true; PTTBPPL.Visible = false; GCPPL.Visible = false; CSPPL.Visible = false; TCSPPL.Visible = false; TESTPPL.Visible = false; } else if (group == "3") { GC.BindGroupDetail(group_id, level); GCPPL.BindPPLDetail(group_id, level); CountPPL.Text = GCPPL.CountPPL(); PTTB.Visible = false; PTT.Visible = false; GC.Visible = true; CS.Visible = false; TCS.Visible = false; TEST.Visible = false; PTTPPL.Visible = false; PTTBPPL.Visible = false; GCPPL.Visible = true; CSPPL.Visible = false; TCSPPL.Visible = false; TESTPPL.Visible = false; } else if (group == "4") { CS.BindGroupDetail(group_id, level); CSPPL.BindPPLDetail(group_id, level); CountPPL.Text = CSPPL.CountPPL(); PTTB.Visible = false; PTT.Visible = false; GC.Visible = false; TCS.Visible = false; CS.Visible = true; TEST.Visible = false; PTTPPL.Visible = false; PTTBPPL.Visible = false; GCPPL.Visible = false; CSPPL.Visible = true; TCSPPL.Visible = false; TESTPPL.Visible = false; } else if (group == "5") { TCS.BindGroupDetail(group_id, level); TCSPPL.BindPPLDetail(group_id, level); CountPPL.Text = TCSPPL.CountPPL(); PTTB.Visible = false; PTT.Visible = false; GC.Visible = false; CS.Visible = false; TCS.Visible = true; TEST.Visible = false; PTTPPL.Visible = false; PTTBPPL.Visible = false; GCPPL.Visible = false; CSPPL.Visible = false; TCSPPL.Visible = true; TESTPPL.Visible = false; } else if (group == "6") { TEST.BindGroupDetail(group_id, level); TESTPPL.BindPPLDetail(group_id, level); PTTB.Visible = false; PTT.Visible = false; GC.Visible = false; TCS.Visible = false; CS.Visible = false; TEST.Visible = true; PTTPPL.Visible = false; PTTBPPL.Visible = false; GCPPL.Visible = false; CSPPL.Visible = false; TCSPPL.Visible = false; TESTPPL.Visible = true; } else { GROUPLabel.Text = "-"; PPLLabel.Text = "-"; PTTB.Visible = false; PTT.Visible = false; GC.Visible = false; CS.Visible = false; TCS.Visible = false; TEST.Visible = false; PTTPPL.Visible = false; PTTBPPL.Visible = false; GCPPL.Visible = false; CSPPL.Visible = false; TCSPPL.Visible = false; TESTPPL.Visible = false; } //setEnableBtn(); }
private void AppInitialize() { AppContainer = ContainerHelper.SetupContainer( out var container , null , _containerHelperSettings ); _container = container; SetupTracing(); var loggerTracker = AppContainer.Resolve <ILoggerTracker>(); var myLoggerName = typeof(App).FullName; loggerTracker.LoggerRegistered += (sender, args) => { if (args.Logger.Name == myLoggerName) { args.Logger.Trace( "Received logger for application in LoggerRegistered handler." ); } else { if (Logger == null) { System.Diagnostics.Debug.WriteLine( "got a logger but i don't have one yet" ); } } }; Logger = AppContainer.Resolve <ILogger>( new TypedParameter( typeof(Type) , typeof(App) ) ); if (AppContainer.IsRegistered <IMenuItemCollection>()) { var menuItemList = AppContainer.Resolve <IMenuItemCollection>(); MenuItemListCollectionView = new ListCollectionView(menuItemList); Resources["MyMenuItemList"] = menuItemList; } var handler = new RoutedEventHandler(MainWindowLoaded); EventManager.RegisterClassHandler( typeof(Window) , FrameworkElement.LoadedEvent , handler ); // var converter = new RegistrationConverter ( AppContainer , objectIdProvider ) ; // Resources[ "RegistrationConverter" ] = converter ; Stage2Complete = true; TCS.SetResult(1); }
public void LoadTCS(string fileName) { _tcs = new TCS(fileName); Invalidate(); }