public void Simple() { int async_cb_called = 0; object o = new object(); var async = new Async(); async.Callback += (a) => { int n; lock (o) { n = ++async_cb_called; } if (n == 3) { a.Close(); } }; new Thread(() => { while (true) { int n; lock (o) { n = async_cb_called; } if (n == 3) { break; } async.Send(); } }).Start(); Loop.Default.Run(); }
public void ArrayIndexAccessMethodAsync() { dynamic array = _app.Dim(new int[] { 0, 1, 2 }).Dynamic(); Async async = new Async(); array.Set(1, 100, async); async.WaitForCompletion(); async = new Async(); dynamic value = array.Get(1, async); async.WaitForCompletion(); Assert.AreEqual(100, (int)value); }
public void ArgumentNullExceptions() { Assert.Throws<ArgumentNullException>(() => new Async(null as Loop)); Assert.Throws<ArgumentNullException>(() => new AsyncWatcher<int>(null as Loop)); var async = new Async(); var asyncWatcher = new AsyncWatcher<int>(); Assert.Throws<ArgumentNullException>(() => asyncWatcher.Send(null as IEnumerable<int>)); async.Close(); asyncWatcher.Close (); }
/// <summary> /// 操作取得。 /// </summary> /// <param name="operation">操作名称。</param> /// <param name="operationTypeInfo">操作タイプ情報。</param> /// <param name="async">非同期実行オブジェクト。</param> /// <returns>操作</returns> internal FriendlyOperation this[string operation, OperationTypeInfo operationTypeInfo, Async async] { get { if (async == null) { return new FriendlyOperationOwner(this, operationTypeInfo, operation).FriendlyOperation; } else { async.Initialize(this); return new AsyncFriendlyOperationOwner(async, operationTypeInfo, operation).FriendlyOperation; } } }
/// <summary> /// FriendlyOperationを取得。 /// </summary> /// <param name="target">対象。</param> /// <param name="name">操作名称。</param> /// <param name="async">非同期実行オブジェクト。</param> /// <param name="typeInfo">操作タイプ情報。</param> /// <returns>FriendlyOperation。</returns> internal static FriendlyOperation GetFriendlyOperation(AppFriend target, string name, Async async, OperationTypeInfo typeInfo) { if (async != null && typeInfo != null) { return target[name, typeInfo, async]; } else if (async != null) { return target[name, async]; } else if (typeInfo != null) { return target[name, typeInfo]; } return target[name]; }
/// <summary> /// Selects a certain node. /// Executes asynchronously. /// </summary> /// <param name="async">Asynchronous execution.</param> #else /// <summary> /// ノードを選択します。 /// 非同期で実行します。 /// </summary> /// <param name="async">非同期オブジェクト。</param> #endif public void EmulateSelect(Async async) { App[typeof(FormsTreeNode), "EmulateSelectInTarget", async](AppVar); }
/// <summary> /// 引数を解決する。 /// </summary> /// <param name="srcArgs">元引数。</param> /// <param name="async">非同期実行オブジェクト。</param> /// <param name="typeInfo">操作タイプ情報。</param> /// <returns>解決した後の引数。</returns> internal static object[] ResolveArguments(object[] srcArgs, out Async async, out OperationTypeInfo typeInfo) { return(ResolveAsyncAndTypeInfo(srcArgs, out async, out typeInfo)); }
/// <summary> /// Changes the DropDown Visible state. /// If a dropdown is opened, CBN_DROPDOWN is notified. /// If a drop down is closed, CBN_CLOSEUP is notified. /// Executes asynchronously. /// </summary> /// <param name="visible">Visible state of the window.</param> /// <param name="async">Asynchronous execution object.</param> #else /// <summary> /// リストの表示、非表示を設定します。 /// 表示した場合はCBN_DROPDOWN、閉じた場合はCBN_CLOSEUPの通知が発生します。 /// 非同期で実行します。 /// </summary> /// <param name="visible">表示するか。</param> /// <param name="async">非同期実行オブジェクト。</param> #endif public void EmulateChangeDropDownVisible(bool visible, Async async) { App[GetType(), "EmulateChangeDropDownVisibleInTarget", async](Handle, visible); }
/// <summary> /// Modifies the node's text. /// Executes asynchronously. /// </summary> /// <param name="nodeText">New text to use.</param> /// <param name="async">Asynchronous execution.</param> #else /// <summary> /// ノード名を編集します。 /// 非同期で実行します。 /// </summary> /// <param name="nodeText">テキスト。</param> /// <param name="async">非同期オブジェクト。</param> #endif public void EmulateEditLabel(string nodeText, Async async) { App[typeof(FormsTreeNode), "EmulateEditLabelInTarget", async](AppVar, nodeText); }
/// <summary> /// Sets the selected date. /// Produces MCN_SELCHANGE and MCN_SELECT notifications. /// Executes asynchronously. /// </summary> /// <param name="day">The date to select.</param> /// <param name="async">Asynchronous execution object.</param> #else /// <summary> /// 現在の選択日付を設定します。 /// MCN_SELCHANGE、MCN_SELECTの通知が発生します。 /// 非同期で実行します。 /// </summary> /// <param name="day">選択する日時。</param> /// <param name="async">非同期実行オブジェクト。</param> #endif public void EmulateSelectDay(DateTime day, Async async) { App[GetType(), "EmulateSelectDayInTarget", async](Handle, day); }
/// <summary> /// Sets the current scroll position. /// Produces a WM_HSCROLL or WM_VSCROLL notification. /// Uses SB_THUMBTRACK type scrolling. /// Executes asynchronously. /// </summary> /// <param name="pos">The position to set</param> /// <param name="async">Asynchronous execution object.</param> #else /// <summary> /// スクロールバーの現在位置を設定します。 /// WM_HSCROLL、もしくはWM_VSCROLLの通知が発生します。 /// スクロールのタイプはSB_THUMBTRACKです。 /// 非同期で実行します。 /// </summary> /// <param name="pos">現在位置。</param> /// <param name="async">非同期実行オブジェクト。</param> #endif public void EmulateScroll(int pos, Async async) { App[GetType(), "EmulateScrollInTarget", async](Handle, IsVertical, pos); }
public async Task <int?> AsyncFunctionWithNullableInt/*Expect:NotNullOnImplicitCanBeNull[Implicit]*/ () { return(await Async.CanBeNullResult <int?>() /*Expect:AssignNullToNotNullAttribute*/); // This warning results from the explicit NotNull }
/// <summary> /// Changes the control's text. /// Notifies EN_CHANGE and EN_UPDATE. /// For RichEdit20A and RichEdit20W, notice only occurs when the event mask is set.. /// Executes asynchronously. /// </summary> /// <param name="newText">New text</param> /// <param name="async">Asynchronous execution object.</param> #else /// <summary> /// テキストを変更します。 /// EN_CHANGE、EN_UPDATEの通知が発生します。 /// RichEdit20A、RichEdit20Wの場合は、イベントマスクが設定されている場合のみ通知が発生します。 /// 非同期で実行します。 /// </summary> /// <param name="newText">新たなテキスト。</param> /// <param name="async">非同期実行オブジェクト。</param> #endif public void EmulateChangeText(string newText, Async async) { App[GetType(), "EmulateChangeTextInTarget", async](Handle, newText); }
/// <summary> /// Set current selected DateTime. /// Executes asynchronously. /// </summary> /// <param name="datetime">DateTime.</param> /// <param name="async">Asynchronous execution.</param> #else /// <summary> /// 現在日時を設定します。 /// 非同期で実行します。 /// </summary> /// <param name="datetime">日時。</param> /// <param name="async">非同期実行オブジェクト。</param> #endif public void EmulateChangeDate(DateTime datetime, Async async) { InvokeStatic(EmulateChangeDate, async, datetime); }
public ApiModule(ILogService server, IApplicationService application) : base("/api") { Server = server ?? throw new ArgumentNullException(nameof(server)); Application = application ?? throw new ArgumentNullException(nameof(application)); Get["/"] = _ => { var response = (Response)JsonConvert.SerializeObject(new { id = AssemblyInfo.Id, name = AssemblyInfo.Name, description = AssemblyInfo.Description, version = AssemblyInfo.Version, build = AssemblyInfo.Build, copyright = AssemblyInfo.Copyright, hash = AssemblyInfo.Hash }); response.ContentType = "application/json"; return(response); }; Get["/apps"] = _ => { var apps = Async.Execute(() => Application.GetApplications()); var response = (Response)JsonConvert.SerializeObject(apps); response.ContentType = "application/json"; return(response); }; Get["/apps/{app}/logs"] = _ => { var logs = Async.Execute <List <Log> >(() => Server.GetLogEntries(_.app, DateTime.Now.Subtract(new TimeSpan(1, 0, 0)), DateTime.Now)); var response = (Response)JsonConvert.SerializeObject(logs); response.ContentType = "application/json"; return(response); }; Get["/apps/{app}/logs/{startDate}/{endDate}"] = _ => { var start = DateTime.ParseExact(_.startDate, "yyyyMMddTHHmmss", null); var end = DateTime.ParseExact(_.endDate, "yyyyMMddTHHmmss", null); var logs = Async.Execute <List <Log> >(() => Server.GetLogEntries(_.app, start, end)); var response = (Response)JsonConvert.SerializeObject(logs); response.ContentType = "application/json"; return(response); }; Get["/apps/{app}/logs/{startDate}/{endDate}/{searchTerm}"] = _ => { var start = DateTime.ParseExact(_.startDate, "yyyyMMddTHHmmss", null); var end = DateTime.ParseExact(_.endDate, "yyyyMMddTHHmmss", null); var logs = Async.Execute <List <Log> >(() => Server.SearchLogEntries(_.app, start, end, _.searchTerm)); var response = (Response)JsonConvert.SerializeObject(logs); response.ContentType = "application/json"; return(response); }; }
/// <summary> /// WM_COMMANDを通知します。 /// 非同期で実行します。 /// </summary> /// <param name="app">アプリケーション操作クラス。</param> /// <param name="handle">ハンドル。</param> /// <param name="code">通知コード。</param> /// <param name="async">非同期実行オブジェクト。</param> internal static void SendCommand(WindowsAppFriend app, IntPtr handle, int code, Async async) { app["SendCommand", async](handle, code); }
/// <summary> /// Set's the calendar's display mode. /// Produces a MCN_VIEWCHANGE notification. /// Executes asynchronously. /// </summary> /// <param name="view">The display mode.</param> /// <param name="async">Asynchronous execution object.</param> #else /// <summary> /// 表示モードを設定します。 /// MCN_VIEWCHANGEの通知が発生します。 /// 非同期で実行します。 /// </summary> /// <param name="view">表示モード。</param> /// <param name="async">非同期実行オブジェクト。</param> #endif public void EmulateChangeView(MonthCalendarView view, Async async) { App[GetType(), "EmulateChangeViewInTarget", async](Handle, view); }
/// <summary> /// Sets the selected date range. /// Use this when selecting multiple dates. /// Produces MCN_SELCHANGE and MCN_SELECT notifications. /// Executes asynchronously. /// </summary> /// <param name="min">The start date.</param> /// <param name="max">The end date.</param> /// <param name="async">Asynchronous execution object.</param> #else /// <summary> /// 現在の選択範囲を設定します。 /// 複数選択の場合に使用します。 /// MCN_SELCHANGE、MCN_SELECTの通知が発生します。 /// 非同期で実行します。 /// </summary> /// <param name="min">最小日付。</param> /// <param name="max">最大日付。</param> /// <param name="async">非同期実行オブジェクト。</param> #endif public void EmulateSelectDay(DateTime min, DateTime max, Async async) { App[GetType(), "EmulateSelectDayInTarget", async](Handle, min, max); }
private void SendUserTaskEmail(long taskId) { try { logger.DebugFormat("Sending User Task Email with Task ID [{0}]", taskId); UserTaskEmailVM taskDetail = userTaskManagement.GetUserTaskEmailDetails(taskId); if (taskDetail == null) { logger.DebugFormat("No Task Found With ID [{0}]", taskId); return; } string styleSheet = System.IO.File.ReadAllText(Server.MapPath("~/Themes/finance-1/css/emailstyle.css")); taskDetail.StyleSheet = styleSheet; var viewsPath = Path.GetFullPath(HostingEnvironment.MapPath(@"~/Views/EmailTemplates/UserTask.cshtml")); string template = System.IO.File.ReadAllText(viewsPath); string uniqueNumber = Guid.NewGuid().ToString(); string body = Engine.Razor.RunCompile(template, string.Format("UserTaskEmail_{0}", uniqueNumber), typeof(UserTaskEmailVM), taskDetail); if (taskDetail != null && taskDetail.UserTaskDetails.Count > 0) { UserTaskDetailVM activeTaskDetail = taskDetail.UserTaskDetails.FirstOrDefault(x => x.IsActive == true); comManagement.Recipient = activeTaskDetail.ToUserEmail; comManagement.Subject = string.Format("Ticket {0} - {1} ", taskDetail.TicketNumber, taskDetail.Title); comManagement.Body = body; List <string> rcc = new List <string>(); rcc.Add(activeTaskDetail.FromUserEmail); logger.DebugFormat("Getting user with roles [{0}]", UserRoles.Manager); var role = RoleManager.Roles.Where(x => x.Name.Equals(UserRoles.Manager)).FirstOrDefault(); var userDepartments = userdepartmentManagement.GetAllUserDepartmentById(User.Identity.GetUserId()); if (userDepartments != null && userDepartments.Count() > 0) { var primaryDepartment = userDepartments.Where(x => x.IsPrimary).SingleOrDefault(); var users = userManagement.GetAllUsersByRoleAndDepartment(role.Id, primaryDepartment.DepartmentID); logger.DebugFormat("Total [{0}] users found with roles [{1}]", UserRoles.Manager, users.Count()); if (users.Count() > 0) { foreach (var user in users) { if (!user.Email.Equals(activeTaskDetail.FromUserEmail) && !user.Email.Equals(activeTaskDetail.ToUserEmail)) { rcc.Add(user.Email); } } } comManagement.RecipientCC = rcc; comManagement.HeaderImage = Server.MapPath("~/Themes/finance-1/img/logo.png"); Async.Do(() => comManagement.SendEmail()); logger.DebugFormat("Email Successfully Send"); } } } catch (Exception ex) { logger.ErrorFormat("Exception Raised : Message[{0}] Stack Trace [{1}] ", ex.Message, ex.StackTrace); } }
/// <summary> /// Sets the selected item. /// If the selected index is changed, CBN_SELENDOK and CBN_SELCHANGE are notified. /// For a ComboBoxEx32 that is not a dropdown list, CBN_EDITCHANGE is notified as well. /// Executes asynchronously. /// </summary> /// <param name="index">Index of the item to select.</param> /// <param name="async">Asynchronous execution object.</param> #else /// <summary> /// アイテムを選択します。 /// 選択位置の変更があった場合、CBN_SELENDOK、CBN_SELCHANGEの通知が発生します。 /// ComboBoxEx32でドロップダウンリストでない場合はCBN_EDITCHANGEも発生します。 /// 非同期で実行します。 /// </summary> /// <param name="index">アイテムのインデックス。</param> /// <param name="async">非同期実行オブジェクト。</param> #endif public void EmulateSelectItem(int index, Async async) { App[GetType(), "EmulateSelectItemInTarget", async](Handle, index); }
public void Close() { Window.Dynamic().Close(); Async.WaitForCompletion(); }
/// <summary> /// Changes the selection state of an item. /// Causes an LVN_ITEMCHANGING and LVN_ITEMCHANGED notification. /// Executes asynchronously. /// </summary> /// <param name="itemIndex">Index of the item.</param> /// <param name="isSelect">State to set.</param> /// <param name="async">Asynchronous execution object.</param> #else /// <summary> /// アイテムの選択状態を変更します。 /// LVN_ITEMCHANGING, LVN_ITEMCHANGEDの通知が発生します。 /// 非同期で実行します。 /// </summary> /// <param name="itemIndex">アイテムインデックス。</param> /// <param name="isSelect">選択状態。</param> /// <param name="async">非同期実行オブジェクト。</param> #endif public void EmulateSelect(int itemIndex, bool isSelect, Async async) { EmulateChangeItemState(itemIndex, LVIS.SELECTED, (isSelect ? LVIS.SELECTED : 0), async); }
public async Task Save(string msg, string fileName) { await Task.Run(async() => { try { //フォーカスしないようにする //ShowWindow(mainWindowHandle.ToInt32(), SW_HIDE); await Task.Delay(100); //再生完了待機 while (!saveButton.IsEnabled) { Console.WriteLine("saveBtn is not enabled"); await Task.Delay(100); } talkTextBox.EmulateChangeText(msg); var async = new Async(); saveButton.EmulateClick(async); //名前を付けて保存ダイアログ var saveFileWindow = uiTreeTop.WaitForNextModal(); var saveFileDialog = new NativeMessageBox(saveFileWindow); //ファイル名を入力 //右上の検索欄にも入力されてしまうが無視 var edits = saveFileDialog.Window.GetFromWindowClass("Edit"); foreach (var t in edits) { var edit = new NativeEdit(t); edit.EmulateChangeText(fileName); } saveFileDialog.EmulateButtonClick("保存(&S)"); //saveFileWindow.WaitForDestroy(); //出力状況を表示するダイアログの表示を待つ Console.WriteLine("waiting for showing progress window"); var progressWindow = uiTreeTop.WaitForNextModal(); if (progressWindow == null) { progressWindow = uiTreeTop.WaitForNextModal(); } Console.WriteLine("showed " + progressWindow.GetWindowText()); var tokenSource = new CancellationTokenSource(); var task = new TaskFactory().StartNew(() => { //完了通知ダイアログの表示を待つ Console.WriteLine("wationg for showing saving complete window"); var completeWindow = progressWindow.WaitForNextModal(); if (completeWindow != null) { Console.WriteLine("showed " + completeWindow.GetWindowText()); Console.WriteLine(DateTime.Now); try { var completeDialog = new NativeMessageBox(completeWindow); completeDialog.EmulateButtonClick("OK"); Console.WriteLine("wating for destroying"); completeWindow.WaitForDestroy(); Console.WriteLine("finish"); } catch (Exception e) { Console.WriteLine(e); } } }, tokenSource.Token); try { Console.WriteLine(DateTime.Now); if (!task.Wait(5000)) { tokenSource.Cancel(); Console.WriteLine("timeout"); Console.WriteLine(DateTime.Now); var windows = WindowControl.GetTopLevelWindows(uiTreeTop.App); foreach (var window in windows) { Console.WriteLine(window.GetWindowText()); var btnList = window.LogicalTree().ByType <Button>(); var count = btnList.Count; for (int i = 0; i < count; i++) { var btn = new WPFButtonBase(btnList[i]); var btnTxtList = btn.LogicalTree(TreeRunDirection.Descendants).ByType <TextBlock>(); if (btnTxtList.Count == 1) { var btnTxt = new WPFTextBlock(btnTxtList.Single()); Console.WriteLine(btnTxt.Text); if (btnTxt.Text.Equals("キャンセル")) { btn.EmulateClick(); } } } } var completeWindow = progressWindow.WaitForNextModal(); Console.WriteLine("showed2 " + completeWindow.GetWindowText()); Console.WriteLine("2" + DateTime.Now); var completeDialog = new NativeMessageBox(completeWindow); completeDialog.EmulateButtonClick("OK"); Console.WriteLine("wating for destroying2"); completeWindow.WaitForDestroy(); Console.WriteLine("finish2"); } } catch (AggregateException) { //タスクがキャンセルされた Console.WriteLine("task was canceled"); var completeWindow = WindowControl.FromZTop(uiTreeTop.App); Console.WriteLine("showed3 " + completeWindow.GetWindowText()); var completeDialog = new NativeMessageBox(completeWindow); completeDialog.EmulateButtonClick("OK"); Console.WriteLine("wating for destroying3"); completeWindow.WaitForDestroy(); Console.WriteLine("finish3"); } if (!async.IsCompleted) { try { Console.WriteLine("wating for async finish"); async.WaitForCompletion(); } catch (Exception e) { Console.WriteLine(e); } } } finally { //ShowWindow(mainWindowHandle.ToInt32(), SW_MINIMIZE); Console.WriteLine("complete saving"); } }); }
private void AsyncRun(DateTime snapTime, Sconit.Entity.ACC.User user, CodeMaster.SnapType snapType) { Async async = new Async(mrpMgr.GenMrpSnapShot); async.BeginInvoke(snapTime, user, false, snapType, null, null); }
/// <summary> /// Edits an item in the list. /// Causes an LVN_BEGINLABELEDIT and LVN_ENDLABELEDIT notification. /// Executes asynchronously. /// </summary> /// <param name="itemIndex">Index of the item.</param> /// <param name="text">Text to set.</param> /// <param name="async">Asynchronous execution object.</param> #else /// <summary> /// 指定のアイテムを編集します。 /// LVN_BEGINLABELEDIT、LVN_ENDLABELEDITが発生します。 /// 非同期で実行します。 /// </summary> /// <param name="itemIndex">アイテムインデックス。</param> /// <param name="text">テキスト。</param> /// <param name="async">非同期実行オブジェクト。</param> #endif public void EmulateEdit(int itemIndex, string text, Async async) { App[GetType(), "EmulateEditInTarget", async](Handle, itemIndex, text, SelectedIndices); }
/// <summary> /// Activate MdiChild with the specified index. /// Executes asynchronously. /// </summary> /// <param name="index">Item index.</param> /// <param name="async">Asynchronous execution.</param> #else /// <summary> /// 指定のインデックスのMdiChildをアクティブにします。 /// 非同期で実行します。 /// </summary> /// <param name="index">インデックス。</param> /// <param name="async">非同期実行オブジェクト。</param> #endif public void EmulateChangeActiveMdiChild(int index, Async async) => App[typeof(FormsMdiClient), "EmulateChangeActiveMdiChild"](this, index, async);
/// <summary> /// Performs a click and notifies BN_CLICKED. /// Executes asynchronously. /// </summary> /// <param name="async">Asynchronous execution object.</param> #else /// <summary> /// クリック。 /// BN_CLICKEDの通知が発生します。 /// 非同期で実行します。 /// </summary> /// <param name="async">非同期実行オブジェクト。</param> #endif public void EmulateClick(Async async) { App[GetType(), "EmulateClickInTarget", async](Handle); }
/// <summary> /// Activate MdiChild with specified text. /// Executes asynchronously. /// </summary> /// <param name="text">Text to use.</param> /// <param name="async">Asynchronous execution.</param> #else /// <summary> /// 指定のテキストを持つMdiChildをアクティブにします。 /// 非同期で実行します。 /// </summary> /// <param name="text">テキスト。</param> /// <param name="async">非同期実行オブジェクト。</param> #endif public void EmulateChangeActiveMdiChild(string text, Async async) => App[typeof(FormsMdiClient), "EmulateChangeActiveMdiChild"](this, text, async);
/// <summary> /// <para>Returns the status of an asynchronous job.</para> /// <para>Warning: This endpoint is in beta and is subject to minor but possibly /// backwards-incompatible changes.</para> /// </summary> /// <param name="pollArg">The request parameters</param> /// <returns>The task that represents the asynchronous send operation. The TResult /// parameter contains the response from the server.</returns> /// <exception cref="Dropbox.Api.ApiException{Async.PollError}">Thrown if there is an /// error processing the request; This will contain a <see /// cref="Async.PollError"/>.</exception> public t.Task<JobStatus> CheckJobStatusAsync(Async.PollArg pollArg) { return this.Transport.SendRpcRequestAsync<Async.PollArg, JobStatus, Async.PollError>(pollArg, "api", "/sharing/check_job_status", Async.PollArg.Encoder, JobStatus.Decoder, Async.PollError.Decoder); }
private void LoadReports() { Async.CancelPending(this); if (_context == null) { return; } Async.Request( this, (IBrowsePatientDataService service) => { var request = new GetDataRequest { ListReportsRequest = new ListReportsRequest(null, _context.OrderRef), ListPatientProfilesRequest = new ListPatientProfilesRequest(_context.PatientRef), GetOrderDetailRequest = new GetOrderDetailRequest(_context.OrderRef, false, true, false, false, false, false) }; return(service.GetData(request)); }, response => { var procedure = CollectionUtils.FirstElement(response.GetOrderDetailResponse.Order.Procedures); if (procedure != null) { var facilityCode = procedure.PerformingFacility.InformationAuthority.Code; var matchingProfile = CollectionUtils.SelectFirst( response.ListPatientProfilesResponse.Profiles, summary => summary.Mrn.AssigningAuthority.Code == facilityCode); _patientProfileRef = matchingProfile != null ? matchingProfile.PatientProfileRef : null; } var reports = new List <CommonReportListItem>(); CollectionUtils.ForEach(response.ListReportsResponse.Reports, delegate(ReportListItem item) { var existingItem = CollectionUtils.SelectFirst(reports, crli => Equals(crli.ReportRef, item.ReportRef)); if (existingItem != null) { existingItem.AddReportListItem(item); } else { reports.Add(new CommonReportListItem(item.ProcedureRef, item.ReportRef, item)); } }); _reports = reports; _selectedReport = CollectionUtils.FirstElement(_reports); OnReportSelectionChanged(); NotifyAllPropertiesChanged(); }, exception => { _reports = new List <CommonReportListItem>(); _selectedReport = null; ExceptionHandler.Report(exception, this.Host.DesktopWindow); OnReportSelectionChanged(); NotifyAllPropertiesChanged(); }); }
/// <summary> /// Collapses the node. /// Executes asynchronously. /// </summary> /// <param name="async">Asynchronous execution.</param> #else /// <summary> /// 展開を閉じます。 /// 非同期で実行します。 /// </summary> /// <param name="async">非同期実行オブジェクト。</param> #endif public void EmulateCollapse(Async async) { App[typeof(FormsTreeNode), "EmulateCollapseInTarget", async](AppVar); }
public Task <T> CallAsync <T>(RedisCommand <T> command) { return(Async.CallAsync(command)); }
/// <summary> /// Sets the node's checked state. /// Executes asynchronously. /// </summary> /// <param name="check">true to set the node as checked.</param> /// <param name="async">Asynchronous execution.</param> #else /// <summary> /// チェック状態を設定します。 /// 非同期で実行します。 /// </summary> /// <param name="check">true:チェック</param> /// <param name="async">非同期オブジェクト</param> #endif public void EmulateCheck(bool check, Async async) { App[typeof(FormsTreeNode), "EmulateCheckInTarget", async](AppVar, check); }
public Task <bool> ConnectAsync() { return(Async.ConnectAsync()); }
/// <summary> /// FriendlyOperationを取得。 /// </summary> /// <param name="target">対象。</param> /// <param name="name">操作名称。</param> /// <param name="async">非同期実行オブジェクト。</param> /// <param name="typeInfo">操作タイプ情報。</param> /// <returns>FriendlyOperation。</returns> internal static FriendlyOperation GetFriendlyOperation(AppFriend target, string name, Async async, OperationTypeInfo typeInfo) { if (async != null && typeInfo != null) { return(target[name, typeInfo, async]); } else if (async != null) { return(target[name, async]); } else if (typeInfo != null) { return(target[name, typeInfo]); } return(target[name]); }
public static Task TimeAsync(this IMetricsClient client, Action action, string name) { return(Async.Using(client.StartTimer(name), action)); }
static Kernel GetDefaultKernel(CommonConfigData config, KernelLoadDirective loadDirective) { var repository = new MB3ApiRepository(); var localRepo = GetLocalRepository(); var kernel = new Kernel() { PlaybackControllers = new List <BasePlaybackController>(), //MetadataProviderFactories = MetadataProviderHelper.DefaultProviders(), CommonConfigData = config, //ServiceConfigData = ServiceConfigData.FromFile(ApplicationPaths.ServiceConfigFile), StringData = LocalizedStrings.Instance, ImageResolvers = DefaultImageResolvers(false), MB3ApiRepository = repository, LocalRepo = localRepo, MediaLocationFactory = new MediaLocationFactory(), }; //Kernel.UseNewSQLRepo = config.UseNewSQLRepo; // kernel.StringData.Save(); //save this in case we made mods (no other routine saves this data) if (LoadContext == MBLoadContext.Core) { kernel.PlaybackControllers.Add(new PlaybackController()); } //kernel.EntityResolver = DefaultResolver(kernel.ConfigData); //need a blank root in case plug-ins will add virtual items kernel.RootFolder = new AggregateFolder { Name = "My Media", Id = new Guid("{F6109BAE-CA26-4746-9EBC-1CD233A7B56F}") }; //create our default config panels with localized names kernel.AddConfigPanel(kernel.StringData.GetString("GeneralConfig"), ""); kernel.AddConfigPanel(kernel.StringData.GetString("ViewOptionsConfig"), ""); kernel.AddConfigPanel(kernel.StringData.GetString("ThemesConfig"), ""); kernel.AddConfigPanel(kernel.StringData.GetString("PlaybackConfig"), ""); //kick off log clean up task if needed if (config.LastFileCleanup < DateTime.UtcNow.AddDays(-7)) { Async.Queue(Async.ThreadPoolName.LogfileCleanup, () => { Logger.ReportInfo("Running Logfile clean-up..."); var minDateModified = DateTime.UtcNow.AddDays(-(config.LogFileRetentionDays)); foreach (var source in new DirectoryInfo(ApplicationPaths.AppLogPath).GetFileSystemInfos("*.log") .Where(f => f.LastWriteTimeUtc < minDateModified)) { try { source.Delete(); } catch (Exception e) { Logger.ReportException("Error deleting log file {0}", e, source.Name); } } config.LastFileCleanup = DateTime.UtcNow; config.Save(); }); Async.Queue(Async.ThreadPoolName.ImageCacheCleanup, () => ImageCache.Instance.Clean(DateTime.UtcNow.AddDays(-(Instance.CommonConfigData.CacheFileRetentionDays)))); } return(kernel); }
public static Task <T> TimeAsync <T>(this IMetricsClient client, Func <Task <T> > func, string name) { return(Async.Using(client.StartTimer(name), func)); }
private static void _LoadTableSetBodyAsync <T>( Connectable connectable, Func <IDataReader, TableSetLoaderArgs> tableSetLoader, // main loader delegate method Async <T> async, Type currentTableType) { int loaderReturnValue = 0; int tableIndex = 0; // callback1: a method that is invoked when SQL processing has completed AsyncCallback onSqlRequestComplete = (iAsyncResult) => { Async asyncBegin = null; SqlDataReader reader = null; // async2: data loader processing reader asynchronously var loader = new Action <IDataReader>((readerLoader) => { try { var loaderException = tableSetLoader(reader); if (loaderException != null) { currentTableType = loaderException.TableType; tableIndex = loaderException.TableIndex; throw loaderException.Exception; } // load return value loaderReturnValue = Reader.ReadOutputData(reader, connectable); ((dynamic)async.Result).ReturnValue = loaderReturnValue; } catch (QueryTalkException ex) { if (async.SetResultException(ex)) { async.Exception.ObjectName = ((IName)connectable.Executable).Name; async.Exception.Method = Text.Method.GoAsync; } } catch (System.InvalidCastException) // "Specified cast is not valid." { var mismatchData = Loader.AnalyseInvalidCastException(connectable, currentTableType, tableIndex); // throw exception with accurate report if (mismatchData != null) { throw Reader.TypeMismatchException( ((IName)connectable.Executable).Name, Text.Method.GoAsync, currentTableType, mismatchData, tableIndex); } // throw exception with less accurate report (not likely to happen) else { throw Reader.TypeMismatchException( ((IName)connectable.Executable).Name, Text.Method.GoAsync, currentTableType, new Row <string, string, string>(), tableIndex); } } catch (System.Exception ex) { QueryTalkException exception = new QueryTalkException("Reader._LoadTableSetBodyAsync.Loader", QueryTalkExceptionType.ClrException, ((IName)connectable.Executable).Name, Text.Method.GoAsync, String.Format("table = {0}", currentTableType)); exception.ClrException = ex; async.SetResultException(exception); } finally { if (readerLoader != null) { readerLoader.Close(); } } }); try { asyncBegin = (Async)iAsyncResult.AsyncState; reader = async.Command.EndExecuteReader(iAsyncResult); // ------------------------------------------------------------------------------------------- // here is a gap between two async calls: first is finished, the second is about to begin... // ------------------------------------------------------------------------------------------- async.AsyncResult2 = loader.BeginInvoke(reader, new AsyncCallback( new Action <IAsyncResult>((iAsyncResult2) => { try { loader.EndInvoke(iAsyncResult2); async.EndAsync(); } catch (QueryTalkException ex) { ex.Method = Text.Method.GoAsync; async.SetResultException(ex); async.EndAsync(); } catch (System.Exception ex) { async.SetClrException(ex, "LoadTableSet.AsyncResult2", connectable, Text.Method.GoAsync); async.EndAsync(); } })), null); } catch (QueryTalkException ex) { ex.ObjectName = ((IName)connectable.Executable).Name; ex.Method = Text.Method.GoAsync; async.SetResultException(ex); async.EndAsync(); } catch (System.InvalidCastException) // "Specified cast is not valid." { var mismatchData = Loader.AnalyseInvalidCastException(connectable, currentTableType, tableIndex); // throw exception with accurate report QueryTalkException exception; if (mismatchData != null) { exception = Reader.TypeMismatchException( ((IName)connectable.Executable).Name, Text.Method.GoAsync, currentTableType, mismatchData); } // throw exception with less accurate report (not likely to happen) else { exception = Reader.TypeMismatchException( ((IName)connectable.Executable).Name, Text.Method.GoAsync, currentTableType, new Row <string, string, string>()); } async.SetResultException(exception); async.EndAsync(); } catch (System.Exception ex) { QueryTalkException exception = new QueryTalkException("Reader._LoadTableSetBodyAsync.OnSqlRequestComplete", QueryTalkExceptionType.ClrException, ((IName)connectable.Executable).Name, Text.Method.GoAsync, String.Format("table = {0}", currentTableType)); exception.ClrException = ex; async.SetResultException(exception); async.EndAsync(); } }; async.BeginAsync(connectable, onSqlRequestComplete); }
private void btnAsync_Click(object sender, EventArgs e) { int status = -1; updateConfig(); try { Async sample = new Async(Config.RSCRIPTSRC, Config.WORKINGDIR, Config.SAMPLENUMBER); status = sample.status; //labelStatus.Text = "RScript Processing Status : " + status; updateStatus("Step 3 : Async Processing Status : " + status); } catch(IOException msg){ updateStatus(msg.Message); } }
static void Main() { Async myAsync = new Async(); myAsync.ProcessRead(); }
public async Task <string> AsyncFunction() => await Async.CanBeNullResult <string>() /*Expect:AssignNullToNotNullAttribute[InclGenCode]*/;
/// <summary> /// Changes the text selection. /// Selects all text when startChar is 0 and endChar is -1. Cancels the current selection when startChar is -1. /// For RichEdit20A and RichEdit20W, notifies EN_SELCHANGE if the event mask is set. /// Executes asynchronously. /// </summary> /// <param name="startChar">Character index of the beginning of the selection.</param> /// <param name="endChar">Character index of the end of the selection.</param> /// <param name="async">Asynchronous execution object.</param> #else /// <summary> /// 選択を設定します。 /// 開始位置が0で終了位置が-1のときは、すべてのテキストが選択されます。開始位置が-1のときは、現在の選択が解除されます。 /// RichEdit20A、RichEdit20Wの場合は、イベントマスクが設定されていれば、EN_SELCHANGEの通知が発生します。 /// 非同期で実行します。 /// </summary> /// <param name="startChar">開始文字列</param> /// <param name="endChar">終了文字列</param> /// <param name="async">非同期実行オブジェクト。</param> #endif public void EmulateChangeSelection(int startChar, int endChar, Async async) { App[GetType(), "EmulateChangeSelectionInTarget", async](Handle, startChar, endChar); }
public void SomeOtherMethod(Async async) { }
public static SaveFileDialogDriver Attach_SaveFileDlialog(this WindowsAppFriend app, string title, Async async) { var core = WindowControl.WaitForIdentifyFromWindowText(app, title, async); if (core == null) { return(null); } return(new SaveFileDialogDriver(core)); }
/// <summary> /// Sets the selected state of a specific item in the control. /// Causes a LBN_SELCHANGE notification. /// Please use EmulateChangeCurrentSelectedIndex for single selection list boxes. /// Executes asynchronously. /// </summary> /// <param name="index">Index of the item.</param> /// <param name="isSelect">Selects the item if true, deselects it if false.</param> /// <param name="async">Asynchronous execution object.</param> #else /// <summary> /// 指定のインデックスのアイテムの選択状態を変更します。 /// LBN_SELCHANGEの通知が発生します。 /// 単一選択リストボックスの場合はEmulateChangeCurrentSelectedIndexInTargetを使用してください。 /// 非同期で実行します。 /// </summary> /// <param name="index">インデックス。</param> /// <param name="isSelect">選択状態にする場合はtrueを設定します。</param> /// <param name="async">非同期実行オブジェクト。</param> #endif public void EmulateChangeSelect(int index, bool isSelect, Async async) { App[GetType(), "EmulateChangeSelectInTarget", async](Handle, index, isSelect); }
/// <summary> /// Changes the currently selected index. /// Causes a LBN_SELCHANGE notification. /// Please use EmulateChangeSelect for multiple selection list boxes. /// Executes asynchronously. /// </summary> /// <param name="index">Index to select.</param> /// <param name="async">Asynchronous execution object.</param> #else /// <summary> /// 現在選択されているインデックスを設定します。 /// LBN_SELCHANGEの通知が発生します。 /// 複数選択リストボックスの場合はEmulateChangeSelectを使用してください。 /// 非同期で実行します。 /// </summary> /// <param name="index">選択インデックス。</param> /// <param name="async">非同期実行オブジェクト。</param> #endif public void EmulateChangeCurrentSelectedIndex(int index, Async async) { App[GetType(), "EmulateChangeCurrentSelectedIndexInTarget", async](Handle, index); }
private static IEnumerator Update() { Log.Info("Checking for updates..."); yield return(Async.Detach()); var versionBytes = downloadBytes(versionsStringUrl); if (versionBytes == null) { Log.Info("Failed downloading versions file"); yield break; } var versions = JsonConvert.DeserializeObject <VersionInfo[]>(Encoding.UTF8.GetString(versionBytes)); var md5 = System.Security.Cryptography.MD5.Create(); var updates = versions.Where(update => { var currentMd5 = md5.ComputeHash(System.IO.File.ReadAllBytes(update.FilePath)); return(currentMd5 != update.Md5Hash); }).ToList(); if (updates.Any()) { Log.Info("Updates found:"); foreach (var update in versions) { var name = update.Name; Log.Info($"Updating to {name}"); var bytes = downloadBytes(update.DownloadUrl); if (bytes == null) { Log.Info($"Failed updating to {name}"); Log.Info("Failed downloading new file"); continue; } if (md5.ComputeHash(versionBytes) != update.Md5Hash) { Log.Info($"Failed updating to {name}"); Log.Info("Mismatching md5 hash"); continue; } var oldFilePath = $"{update.FilePath}.old"; if (System.IO.File.Exists(oldFilePath)) { System.IO.File.Delete(oldFilePath); } System.IO.File.Move(update.FilePath, oldFilePath); System.IO.File.WriteAllBytes(update.FilePath, downloadBytes(update.DownloadUrl)); Log.Info($"Updated {name}"); } } else { Log.Info("No updates found!"); } yield return(Async.Attach()); Log.Info("Update checking complete"); }
/// <summary> /// Changes the contents of an item. /// Causes a notice according to the changes. /// Executes asynchronously. /// </summary> /// <param name="item">Item.</param> /// <param name="async">Asynchronous execution object.</param> #else /// <summary> /// アイテムの内容を変更します。 /// 変更内容に応じて通知が発生します。 /// 非同期で実行します。 /// </summary> /// <param name="item">アイテム。</param> /// <param name="async">非同期実行オブジェクト。</param> #endif public void EmulateChangeItem(LVITEM item, Async async) { App[GetType(), "EmulateChangeItemInTarget", async](Handle, item); }
private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e) { Async.RunWorkerAsync(); }
/// <summary> /// Cancels editing asynchronously. /// </summary> /// <param name="async">Asynchronous execution object.</param> #else /// <summary> /// 編集キャンセル。 /// </summary> /// <param name="async">非同期実行オブジェクト。</param> #endif public void EmulateCancelEdit(Async async) { WindowControl edit = new WindowControl(App, SendMessage(LVM_GETEDITCONTROL, IntPtr.Zero, IntPtr.Zero)); edit.SequentialMessage(async, new MessageInfo(NativeCommonDefine.WM_KEYDOWN, 0x1B, 0x10001), new MessageInfo(NativeCommonDefine.WM_CHAR, 0x1B, 0x10001), new MessageInfo(NativeCommonDefine.WM_KEYUP, 0x1B, 0xC0010001)); }
private void Async_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { Async.RunWorkerAsync(); }
/// <summary> /// Changes an item's state. /// Causes an LVN_ITEMCHANGING and LVN_ITEMCHANGED notice. /// Executes asynchronously. /// </summary> /// <param name="itemIndex">Index of the item.</param> /// <param name="mask">State mask.</param> /// <param name="state">State.</param> /// <param name="async">Asynchronous execution object.</param> #else /// <summary> /// 状態を変更します。 /// LVN_ITEMCHANGING, LVN_ITEMCHANGEDの通知が発生します。 /// </summary> /// <param name="itemIndex">アイテムインデックス。</param> /// <param name="mask">状態マスク。</param> /// <param name="state">状態。</param> /// <param name="async">非同期実行オブジェクト。</param> #endif public void EmulateChangeItemState(int itemIndex, LVIS mask, LVIS state, Async async) { App[GetType(), "EmulateChangeItemStateInTarget", async](Handle, itemIndex, mask, state); }
public override void OnClose() { base.OnClose(); Async.SafeClose(m_conn.Connection); }
/// <summary> /// Sets the object's check state. /// If the state changes, BN_CLICKED is notified. /// Executes asynchronously. /// </summary> /// <param name="state">Check state.</param> /// <param name="async">Asynchronous execution object.</param> #else /// <summary> /// チェック状態設定。 /// 状態が変更された場合、BN_CLICKEDの通知が発生します。 /// 非同期で実行します。 /// </summary> /// <param name="state">チェック状態。</param> /// <param name="async">非同期実行オブジェクト。</param> #endif public void EmulateCheck(CheckState state, Async async) { App[GetType(), "EmulateCheckInTarget", async](Handle, state); }
public byte[] Resolve(byte[] Query) { return(Async.RunSync(() => ResolveAsync(Query))); }
/// <summary> /// Sets the current position. /// Produces a UDN_DELTAPOS notification. /// Also produces EN_CHANGE and EN_UPDATE notifications as a pair. /// Also produces a WM_VSCROLL notification. /// Executes asynchronously. /// </summary> /// <param name="pos">Position to set.</param> /// <param name="async">Asynchronous execution object.</param> #else /// <summary> /// 現在位置を設定します。 /// UDN_DELTAPOSの通知が発生します。 /// また、ペアとなるEditにEN_CHANGE、EN_UPDATEの通知が発生します。 /// また、WM_VSCROLLの通知も発生します。 /// 非同期で実行します。 /// </summary> /// <param name="pos">現在位置。</param> /// <param name="async">非同期実行オブジェクト。</param> #endif public void EmulateChangePos(int pos, Async async) { App[GetType(), "EmulateChangePosInTarget", async](Handle, pos); }
public IMessage Resolve(IMessage Query) { return(Async.RunSync(() => ResolveAsync(Query))); }
/// <summary> /// <para>Begins an asynchronous send to the check job status route.</para> /// </summary> /// <param name="pollArg">The request parameters.</param> /// <param name="callback">The method to be called when the asynchronous send is /// completed.</param> /// <param name="state">A user provided object that distinguished this send from other /// send requests.</param> /// <returns>An object that represents the asynchronous send request.</returns> public sys.IAsyncResult BeginCheckJobStatus(Async.PollArg pollArg, sys.AsyncCallback callback, object state = null) { var task = this.CheckJobStatusAsync(pollArg); return enc.Util.ToApm(task, callback, state); }
/// <summary> /// Expands the node. /// Executes asynchronously. /// </summary> /// <param name="async">Asynchronous execution.</param> #else /// <summary> /// 展開します。 /// 非同期で実行します。 /// </summary> /// <param name="async">非同期実行オブジェクト。</param> #endif public void EmulateExpand(Async async) { App[typeof(FormsTreeNode), "EmulateExpandInTarget", async](AppVar); }