public Task Run() { DeviceExtension e = new DeviceExtension { PendingIo = 1, StoppingFlag = false, StoppingEvent = false }; this.Lock = new Lock(1); this.Stopped = false; var mt = Task.Run(() => { nekara.ContextSwitch(); e.StoppingFlag = true; BCSP_IoDecrement(e); nekara.ContextSwitch(); if (e.StoppingEvent) { // Release allocated resource. nekara.ContextSwitch(); this.Stopped = true; } }); BCSP_PnpAdd(e); return(mt); }
public static IApp StartApp(Platform platform, string simulator, bool resetDevice = false) { Platform = platform; if (platform == Platform.Android) { if (resetDevice) { ResetAndroidEmulator(); } return(ConfigureApp .Android .DeviceSerial(DeviceExtension.GetAndroidDevice(simulator)) .InstalledApp(packageName) .StartApp()); } try { if (resetDevice) { ResetiOSSimulator(simulator); } return(ConfigureApp .iOS .DeviceIdentifier(DeviceExtension.GetiOSDeviceID(simulator)) .InstalledApp(packageName) .StartApp()); } catch (Exception ex) { Console.WriteLine("********Error" + ex.Message); Console.WriteLine(ex.StackTrace); return(null); } }
private async void TapBackToDetailPage(object sender, System.EventArgs e) { await DeviceExtension.BeginInvokeOnMainThreadAsync(async() => { await Navigation.PopPopupAsync(); }); }
public Task RunBluetoothDriver() { NekaraManagedClient nekara = RuntimeEnvironment.Client; DeviceExtension e = new DeviceExtension { PendingIo = 1, StoppingFlag = false, StoppingEvent = false }; this.Lock = new Lock(1); this.Stopped = false; var mt = Task.Run(() => { nekara.Api.ContextSwitch(); e.StoppingFlag = true; BCSP_IoDecrement(e); nekara.Api.ContextSwitch(); if (e.StoppingEvent) { // Release allocated resource. nekara.Api.ContextSwitch(); this.Stopped = true; } }); BCSP_PnpAdd(e); return(mt); }
public async Task <ConfirmPopup> Show(string title = null, string message = null, string closeButtonText = null, ICommand closeCommand = null, object closeCommandParameter = null, string acceptButtonText = null, ICommand acceptCommand = null, object acceptCommandParameter = null, bool isAutoClose = false, uint duration = 2000) { // Close Loading Popup if it is showing await LoadingPopup.Instance.Hide(); await DeviceExtension.BeginInvokeOnMainThreadAsync(() => { if (title != null) { LabelConfirmTitle.Text = title; } if (message != null) { LabelConfirmMessage.Text = message; } if (closeButtonText != null) { ButtonConfirmClose.Text = closeButtonText; } ClosedPopupCommand = closeCommand; ClosedPopupCommandParameter = closeCommandParameter; if (acceptButtonText != null) { ButtonConfirmAccept.Text = acceptButtonText; } AcceptCommand = acceptCommand; AcceptCommandParameter = acceptCommandParameter; IsAutoClose = isAutoClose; Duration = duration; }); if (IsClosed) { IsClosed = false; if (isAutoClose && duration > 0) { AutoClosedPopupAfter(duration); } await DeviceExtension.BeginInvokeOnMainThreadAsync(async() => { await Application.Current.MainPage.Navigation.PushPopupAsync(this); }); } return(this); }
private async void BackToDetailPageExe() { if (ViewImagePopUp.Scale == 1) { await DeviceExtension.BeginInvokeOnMainThreadAsync(async() => { await Navigation.PopPopupAsync(); }); } }
public async Task <MessagePopup> Show(string message = null, string closeButtonText = null, ICommand closeCommand = null, object closeCommandParameter = null, string textBackgroundColor = null, bool isAutoClose = false, uint duration = 2000) { // Close Loading Popup if it is showing await LoadingPopup.Instance.Hide(); await DeviceExtension.BeginInvokeOnMainThreadAsync(() => { if (textBackgroundColor != null) { LayoutButton.BackgroundColor = Color.FromHex(textBackgroundColor); } else { LayoutButton.BackgroundColor = backGroundDefault; } if (message != null) { LabelMessageContent.Text = message; } if (closeButtonText != null) { ButtonMessageClose.Text = closeButtonText; } ClosedPopupCommand = closeCommand; ClosedPopupCommandParameter = closeCommandParameter; IsAutoClose = isAutoClose; Duration = duration; }); if (IsClosed) { IsClosed = false; if (isAutoClose && duration > 0) { AutoClosedPopupAfter(duration); } await DeviceExtension.BeginInvokeOnMainThreadAsync(async() => { await Application.Current.MainPage.Navigation.PushPopupAsync(this); }); } return(this); }
private void BCSP_PnpAdd(DeviceExtension e) { int status = BCSP_IoIncrement(e); if (status == 0) { // Do work here. nekara.ContextSwitch(); nekara.Assert(!this.Stopped, "Bug found!"); } BCSP_IoDecrement(e); }
private async void LogoutExecute() { await CheckBusy(async() => { SqLiteService.DeleteAll <UserModel>(); // Navigate to Login page await DeviceExtension.BeginInvokeOnMainThreadAsync(async() => { await Navigation.NavigateAsync(new Uri($"{ManagerPage.NavigationHomeUri}/{ManagerPage.LoginPage}")); }); }); }
public async Task Hide() { if (IsLoading) { await Task.Delay(200); IsLoading = false; await DeviceExtension.BeginInvokeOnMainThreadAsync(async() => { Indicator.IsRunning = false; await Navigation.PopPopupAsync(); }); } }
private async void AcceptPopupEvent(object sender, EventArgs e) { await DeviceExtension.BeginInvokeOnMainThreadAsync(async() => { await Navigation.PopPopupAsync(); }); // waiting for close animation finished await Task.Delay(300); AcceptCommand?.Execute(AcceptCommandParameter); //_popupId++; IsClosed = true; }
private int BCSP_IoIncrement(DeviceExtension e) { nekara.ContextSwitch(); if (e.StoppingFlag) { return(-1); } nekara.ContextSwitch(); using (this.Lock.Acquire()) { e.PendingIo++; } return(0); }
static void ResetiOSSimulator(string iOSSimulator) { if (TestEnvironment.Platform.Equals(TestPlatform.Local)) { var deviceId = DeviceExtension.GetiOSDeviceID(iOSSimulator); if (string.IsNullOrEmpty(deviceId)) { throw new ArgumentException($"No simulator found with device name [{iOSSimulator}]", iOSSimulator); } var shutdownProcess = Process.Start("xcrun", string.Format("simctl shutdown {0}", deviceId)); shutdownProcess.WaitForExit(); var eraseProcess = Process.Start("xcrun", string.Format("simctl erase {0}", deviceId)); eraseProcess.WaitForExit(); } }
private void BCSP_IoDecrement(DeviceExtension e) { int pendingIo; nekara.ContextSwitch(); using (this.Lock.Acquire()) { e.PendingIo--; pendingIo = e.PendingIo; } if (pendingIo == 0) { nekara.ContextSwitch(); e.StoppingEvent = true; } }
private int BCSP_IoIncrement(DeviceExtension e) { NekaraManagedClient nekara = RuntimeEnvironment.Client; nekara.Api.ContextSwitch(); if (e.StoppingFlag) { return(-1); } nekara.Api.ContextSwitch(); using (this.Lock.Acquire()) { e.PendingIo++; } return(0); }
private void BCSP_PnpAdd(DeviceExtension e) { NekaraManagedClient nekara = RuntimeEnvironment.Client; int status = BCSP_IoIncrement(e); if (status == 0) { // Do work here. nekara.Api.ContextSwitch(); // nekara.Assert(!this.Stopped, "Bug found!"); if (this.Stopped) { bugFoundBluetoothDriver = true; } } BCSP_IoDecrement(e); }
private void BCSP_IoDecrement(DeviceExtension e) { NekaraManagedClient nekara = RuntimeEnvironment.Client; int pendingIo; nekara.Api.ContextSwitch(); using (this.Lock.Acquire()) { e.PendingIo--; pendingIo = e.PendingIo; } if (pendingIo == 0) { nekara.Api.ContextSwitch(); e.StoppingEvent = true; } }
public async Task <QRCodePopup> Show(string qrCodeValue, ICommand closeCommand = null, object closeCommandParameter = null, bool isAutoClose = false, uint duration = 2000) { IsClosed = false; if (qrCodeValue == null) { Debug.WriteLine("[Error][Exception]: QRCodePopup cannot be shown because of null QR code value"); return(null); } else { QRCodeView.BarcodeValue = qrCodeValue; } if (closeCommand != null) { ClosePopupCommand = closeCommand; } if (closeCommandParameter != null) { ClosePopupCommandParameter = closeCommandParameter; } IsAutoClose = isAutoClose; Duration = duration; if (isAutoClose && duration > 0) { AutoClosePopupAfter(duration); } await DeviceExtension.BeginInvokeOnMainThreadAsync(async() => { await App.Current.MainPage.Navigation.PushPopupAsync(this); }); return(this); }
public async Task Show(string loadingMessage = null) { await DeviceExtension.BeginInvokeOnMainThreadAsync(() => { LabelMessage.Text = !string.IsNullOrWhiteSpace(loadingMessage) ? loadingMessage : TranslateExtension.Get("Loading"); }); if (IsLoading) { return; } IsLoading = true; await DeviceExtension.BeginInvokeOnMainThreadAsync(async() => { Indicator.IsRunning = true; await Application.Current.MainPage.Navigation.PushPopupAsync(this); }); }