public SchedulableGeneratorThunk (IEnumerator<object> task) { _Task = task; _QueueStep = QueueStep; _QueueStepOnComplete = QueueStepOnComplete; _OnErrorChecked = OnErrorChecked; _Step = Step; }
public HttpServer(TaskScheduler scheduler) { EndPoints = new EndPointList(this); Scheduler = scheduler; RequestOnComplete = _RequestOnComplete; }
public void TryBindToRockServer( string rockUrl, string authKey, OnComplete onComplete ) { TempRockUrl = rockUrl; TempAuthKey = authKey; // this will let us use the url temporarily RockApi.SetRockURL( rockUrl ); RockApi.SetAuthorizationKey( authKey ); // get the config templates GetConfigTemplates( // capute the result callback delegate( bool result ) { // restore the original URLs, so that they only update // if Commit is called. RockApi.SetRockURL( RockURL ); RockApi.SetAuthorizationKey( RockAuthorizationKey ); // now notify the original caller onComplete( result ); } ); }
private void CompleteEventMainThread(object obj) { OnComplete?.Invoke(this, (EventArgs)obj); }
public void ImportGeoIPCountryData(string path, bool ignoreInvalidRows) { _cancelImport = false; FileStream fs = null; IsRunning = true; try { var files = Directory.EnumerateFiles(path, "GeoIPCountryWhois.csv").ToList(); if (!files.Any()) { IsRunning = false; if (OnComplete != null) { OnComplete.Invoke(this, new EventArgs()); } _progressText.Invoke("could not locate file 'GeoIPCountryWhois.csv', aborting."); return; } List <IBulkCopyItem> geopIpCountries = new List <IBulkCopyItem>(); string fileName = files.First(); fs = File.OpenRead(fileName); StreamReader sr = new StreamReader(fs); _progressCallback.Invoke(0); long bytesRead = 0; while (!sr.EndOfStream) { if (_cancelImport) { return; } string lineData = sr.ReadLine(); if (lineData == null) { break; } if (lineData.Length > 0 && lineData[0] == '#') { continue; } bytesRead += lineData.Length; _progressCallback.Invoke((double)fs.Length / bytesRead); MatchCollection mc = Regex.Matches(lineData, "\".*?\""); try { if (mc.Count == 6) { var geoIpCountry = new GeoIPCountryBo() { IPAddressFrom = mc[0].Value.Replace("\"", ""), IPAddressTo = mc[1].Value.Replace("\"", ""), IPFrom = long.Parse(mc[2].Value.Replace("\"", "")), IPTo = long.Parse(mc[3].Value.Replace("\"", "")), CountryCode = mc[4].Value.Replace("\"", ""), CountryName = mc[5].Value.Replace("\"", ""), }; geopIpCountries.Add(new BulkCopyItemBo(geoIpCountry)); } } catch (Exception ex) { _progressText.Invoke("Exception while parsing GeoIPCountry row: " + ex.Message); if (!ignoreInvalidRows) { return; } } } fs.Close(); fs = null; _progressText.Invoke(string.Format("Finished parsing {0} rows from import file. Starting database import", geopIpCountries.Count)); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); _geoIpRepository = new GeoIPRepository(); // GeoIPCountryBo column definition List <ColumnDefinition> geoIpCountryDefinitions = new List <ColumnDefinition>(); geoIpCountryDefinitions.Add(new ColumnDefinition() { Index = 0, ColumnName = "IPFrom", ColumnDataType = typeof(long) }); geoIpCountryDefinitions.Add(new ColumnDefinition() { Index = 1, ColumnName = "IPTo", ColumnDataType = typeof(long) }); geoIpCountryDefinitions.Add(new ColumnDefinition() { Index = 2, ColumnName = "IPAddressFrom", ColumnDataType = typeof(string) }); geoIpCountryDefinitions.Add(new ColumnDefinition() { Index = 3, ColumnName = "IPAddressTo", ColumnDataType = typeof(string) }); geoIpCountryDefinitions.Add(new ColumnDefinition() { Index = 4, ColumnName = "CountryCode", ColumnDataType = typeof(string) }); geoIpCountryDefinitions.Add(new ColumnDefinition() { Index = 5, ColumnName = "CountryName", ColumnDataType = typeof(string) }); _geoIpRepository.ImportGeoIPCountryList(geopIpCountries, geoIpCountryDefinitions, d => _progressCallback(d)); stopwatch.Stop(); _progressText.Invoke("Database import completed after: " + stopwatch.Elapsed); if (OnComplete != null) { OnComplete.Invoke(this, new EventArgs()); } } catch (Exception ex) { _errorStringBuilder.AppendLine(ex.Message); if (OnError != null) { OnError.Invoke(this, new ErrorEventArgs(ex)); } } finally { if (fs != null) { fs.Close(); } IsRunning = false; } }
/// <summary> /// Renders the browser window. /// </summary> /// <param name="idx">Window index</param> private void FileBrowserWindow(int idx) { DirectoryInfo directoryInfo; DirectoryInfo directorySelection; // Get the directory info of the current location FileInfo fileSelection = new FileInfo(directoryLocation); if ((fileSelection.Attributes & FileAttributes.Directory) == FileAttributes.Directory) { directoryInfo = new DirectoryInfo(directoryLocation); //If there is no directory in the current location go back to its parent folder if (directoryInfo.GetDirectories().Length == 0 && title.Equals("Load Robot")) { directoryInfo = directoryInfo.Parent; } } else { directoryInfo = fileSelection.Directory; } //If click Exit, close file browser if (_allowEsc && UnityEngine.GUI.Button(new Rect(410, 10, 80, 20), "Exit", fileBrowserButton)) { Active = false; } //If hit Up One Level, go back to parent folder level if (directoryInfo.Parent != null && UnityEngine.GUI.Button(new Rect(10, 10, 120, 25), "Up One Level", fileBrowserButton)) { directoryInfo = directoryInfo.Parent; directoryLocation = directoryInfo.FullName; selectedDirectoryLocation = directoryInfo.FullName; tempSelection = null; //Reset the target folder list and set the folder to unsearched targetFolderList.Clear(); directorySearched = false; } // Handle the directories list GUILayout.BeginArea(new Rect(10, 35, 480, 300)); GUILayout.Label("When choosing a folder, please select the field/robot folder containing these elements" + " " + "NOT the field/robot itself!", descriptionStyle); directoryScroll = GUILayout.BeginScrollView(directoryScroll); //Create a scrolling list and all the buttons having the folder names directorySelection = SelectList(directoryInfo.GetDirectories(), (DirectoryInfo o) => { return(o.Name); }, new DirectoryInfo(directoryLocation).Name, targetFolderList) as DirectoryInfo; GUILayout.EndScrollView(); GUILayout.EndArea(); if (directorySelection != null && selectedDirectoryLocation != null) { bool doubleClick = directorySelection != null && (Time.time - lastClick) > 0 && (Time.time - lastClick) < DOUBLE_CLICK_TIME; //Use try/catch to prevent users from getting in unauthorized folders try { if (doubleClick) { // If directory contains field or robot files, display error message to user prompting them to select directory // instead of the actual field if (directorySelection.GetFiles("*.bxdf").Length != 0 || directorySelection.GetFiles("*.bxda").Length != 0 || directorySelection.GetFiles("*.bxdj").Length != 0) { UserMessageManager.Dispatch("Please DO NOT select the field/robot itself!", 5); } else { // If a directory without robot/field files was double clicked, jump there directoryLocation = directorySelection.FullName; targetFolderList.Clear(); directorySearched = false; } tempSelection = null; } else { // If directory contains field or robot files, display error message to user prompting them to select directory // instead of the actual field if (directorySelection.GetFiles("*.bxdf").Length != 0 || directorySelection.GetFiles("*.bxda").Length != 0 || directorySelection.GetFiles("*.bxdj").Length != 0) { UserMessageManager.Dispatch("Please DO NOT select the field/robot itself!", 5); } else { // If directory was clicked once, select it as a current path and highlight it selectedDirectoryLocation = directorySelection.FullName; } } } catch (UnauthorizedAccessException e) { UserMessageManager.Dispatch("You don't have the authorization to access this folder", 3f); } } // The manual location box and the select button GUILayout.BeginArea(new Rect(12, 335, 480, 25)); //GUILayout.BeginHorizontal(); const int labelLen = 70; bool twoClicks = directorySelection != null && (Time.time - lastClick) > 0 && (Time.time - lastClick) < DOUBLE_CLICK_TIME; try { if (twoClicks) { //If the file path is greater than labelLen, then it will replace part of the path name with "..." GUILayout.Label(directoryLocation.Length > labelLen ? directoryLocation.Substring(0, 5) + "..." + directoryLocation.Substring(directoryLocation.Length - labelLen + 8) : directoryLocation, pathLabel); } else { //One click displays the path of the selected folder GUILayout.Label(selectedDirectoryLocation.Length > labelLen ? selectedDirectoryLocation.Substring(0, 5) + "..." + selectedDirectoryLocation.Substring(selectedDirectoryLocation.Length - labelLen + 8) : selectedDirectoryLocation, pathLabel); } } catch (UnauthorizedAccessException e) { UserMessageManager.Dispatch("You don't have the authorization to access this folder", 3f); } GUILayout.EndArea(); GUILayout.BeginArea(new Rect(12, 360, 480, 25)); GUILayout.BeginHorizontal(); //When this button is clicked, search the directory for target files if (!directorySearched) { if (GUILayout.Button("Search for Target Directory", fileBrowserButton, GUILayout.Width(250))) { SearchDirectories(directoryInfo); //Notify the user there's nothing related inside the current directory if (targetFolderList.Count == 0) { if (title.Equals("Choose Robot Directory")) { UserMessageManager.Dispatch("No exported robot files found in current directory", 5f); } else if (title.Equals("Choose Field Directory")) { UserMessageManager.Dispatch("No exported robot files found in current directory", 5f); } } } } else { if (GUILayout.Button("Search for Target Directory", searchedButton, GUILayout.Width(250))) { UserMessageManager.Dispatch("The current directory has been searched.", 5f); } } if (GUILayout.Button("Select", fileBrowserButton, GUILayout.Width(68))) { _active = false; OnComplete?.Invoke(selectedDirectoryLocation); } if (directorySelection != null) { lastClick = Time.time; } GUILayout.EndHorizontal(); GUILayout.EndArea(); GUILayout.BeginArea(new Rect(12, 385, 480, 25)); GUILayout.Label("Searching through a large directory takes time. Please be patient :)", descriptionStyle); GUILayout.EndArea(); }
internal PendingOperationManager() { OperationOnComplete = _OperationOnComplete; }
void GetFirstTimeVisitAttribValue( OnComplete onComplete ) { ApplicationApi.GetAttributeForGuid( "655D6FBA-F8C0-4919-9E31-C1C936653555", delegate(System.Net.HttpStatusCode statusCode, string statusDescription, Rock.Client.Attribute model ) { if ( Rock.Mobile.Network.Util.StatusInSuccessRange( statusCode ) == true && model != null ) { TempFirstTimeVisit = model; GetCanCheckInGroupTypeRole( onComplete ); } // Child Role Failed else { onComplete( false ); } } ); }
/// <summary> /// 设置目标图片 从 cache中找 -> 用initSprite 赋值 -> 从Assetbundle中找 —> 从url下载 /// </summary> /// <param name="picName"></param> /// <param name="resourcePath"></param> /// <param name="url"></param> /// <param name="nativeSize"></param> /// <param name="initSprite"></param> /// <param name="onCompleteListener"></param> /// <returns></returns> public bool SetTargetPic( string picName, string resourcePath, string url = null, bool nativeSize = false, Sprite initSprite = null, OnComplete onCompleteListener = null) { PicName = picName; ResourcePath = resourcePath; NativeSize = nativeSize; _onCompleteListener = onCompleteListener; LastCheckTime = 0; if (!ContentImage) { // 如果没有内容图片,则直接切换到完成状态。 SwitchToStatus(StatusComplete); return(true); } //先从Cache中取图片 var sprite = _resourceCache.LoadSpriteFromCache(PicName); if (sprite) { ContentImage.sprite = sprite; if (nativeSize) { ContentImage.SetNativeSize(); } SwitchToStatus(StatusComplete); return(true); } if (initSprite != null) { if (ContentImage) { ContentImage.sprite = initSprite; if (nativeSize) { ContentImage.SetNativeSize(); } if (!ContentImage.gameObject.activeSelf) { ContentImage.gameObject.SetActive(true); } } if (WaitingImage && WaitingImage.gameObject.activeSelf) { WaitingImage.gameObject.SetActive(false); } SwitchToStatus(StatusComplete); return(true); } SwitchToStatus(StatusChecking, initSprite != null); if (!string.IsNullOrEmpty(ResourcePath)) { _downLoadByUrl = false; _resource.StartLoadResource(ResourcePath, PicName); } else { if (!string.IsNullOrEmpty(url)) { _downLoadByUrl = true; if (!_resourceCache.ContainsDownloadTask(picName)) { _resourceCache.StartDownload(picName, url, ContentType.Image); } } } return(false); }
public MoveTask(Train t, EdgeTask edge, OnComplete fn) : base(t, fn) { org = edge; org.Trains.Add(t); }
private void OnAllDialogSeen() { OnComplete?.Invoke(); }
public IEnumerator DownloadUpdateFromServer(string pBundleName, OnProgressByRatio onProgress = null, OnComplete pOnCompleted = null, OnError pOnError = null) { yield return(new WaitForEndOfFrame()); string pSavePath = GetAssetBundleFilePath(pBundleName); Debug.Log(pSavePath); if (IsBundleCachingVersionCheck(pBundleName)) { onProgress = null; if (GetBundle(pBundleName)) { if (pOnCompleted != null) { pOnCompleted(); } yield break; } } using (WWW caching = WWW.LoadFromCacheOrDownload(pSavePath, this.serverBundleHash.GetAssetBundleHash(pBundleName))) { if (onProgress != null) { while (!caching.isDone && string.IsNullOrEmpty(caching.error)) { //yield return new WaitForSeconds(2f); //if (caching != null) { caching.Dispose(); } if (onProgress != null) { //Debug.Log(pBundleName + " DownloadUpdateFromServer = " + caching.progress); onProgress(caching.progress); } yield return(new WaitForEndOfFrame()); } } else { //if (caching != null) { caching.Dispose(); } yield return(caching); } if (string.IsNullOrEmpty(caching.error)) { this.loadedBundles.Add(pBundleName, new STLoadedBundle(caching.assetBundle)); Debug.Log("Complete DownloadUpdateFromServer = " + caching.progress); // add hash bundle write complete file if (this.localBundleHash.ContainsKey(pBundleName)) { this.localBundleHash.Remove(pBundleName); } // update playerpref hash file this.localBundleHash.Add(pBundleName, this.serverBundleHash.GetAssetBundleHash(pBundleName).ToString()); SaveBundleHashPrefs(PREFS_KEY, this.localBundleHash); if (onProgress != null) { onProgress(caching.progress); } if (pOnCompleted != null) { pOnCompleted(); } } else { Debug.Log("DownloadUpdateFromServer:" + caching.error); if (pOnError != null) { pOnError(caching.error); } } } }
private void LoadingComplete() { OnComplete?.Invoke(this._models); application.LoadScene(SceneName.Main); }
// フェードアウトを開始する public void FadeOut( float t_time, Color t_color, OnComplete t_cb ) { callBack = t_cb; to = from = t_color; from.a = 0; time = t_time; StartSequence( "FadeUpdate" ); }
void GetCampuses( OnComplete onComplete ) { // get the campuses RockApi.Get_Campuses( "?$expand=Location", delegate(System.Net.HttpStatusCode statusCode, string statusDescription, List<Rock.Client.Campus> model ) { if ( Rock.Mobile.Network.Util.StatusInSuccessRange( statusCode ) == true ) { TempCampuses = model; GetMaritalValues( onComplete ); } // Campuses failed else { onComplete( false ); } } ); }
void GetChildGroupTypeRole( OnComplete onComplete ) { ApplicationApi.GetGroupTypeRoleForGuid( Rock.Client.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_CHILD, delegate(System.Net.HttpStatusCode statusCode, string statusDescription, List<Rock.Client.GroupTypeRole> model ) { if ( Rock.Mobile.Network.Util.StatusInSuccessRange( statusCode ) == true && model != null && model.Count > 0 ) { TempChildRole = model[ 0 ]; GetAdultGroupTypeRole( onComplete ); } // Child Role Failed else { onComplete( false ); } } ); }
/// <summary> /// Constructor. /// </summary> /// <param name="complete">Optional completion callback.</param> /// <param name="type">Tween type.</param> public ColorTween(OnComplete complete, uint type = PERSIST) : base(0, type, complete, null) { Color = new Color(); }
void GetSchoolGrades( OnComplete onComplete ) { ApplicationApi.GetDefinedValuesForDefinedType( Rock.Client.SystemGuid.DefinedType.SCHOOL_GRADES, delegate(System.Net.HttpStatusCode statusCode, string statusDescription, List<Rock.Client.DefinedValue> model ) { if ( Rock.Mobile.Network.Util.StatusInSuccessRange( statusCode ) == true ) { TempSchoolGrades = model; GetChildGroupTypeRole( onComplete ); } // School Grades Failed else { onComplete( false ); } } ); }
private void HandleComplete() { OnProgress?.Invoke(1.0f); OnComplete?.Invoke(this); }
public ReadToEndThunk() { Buffer = new CharacterBuffer(); OnDecodeComplete = _OnDecodeComplete; }
protected void Complete() { OnComplete?.Invoke(this); }
protected bool Equals(OnComplete other) { return(true); }
public virtual void Terminate() { OnComplete?.Invoke(); }
public void ImportGeoIPCityData(string path, bool ignoreInvalidRows) { _cancelImport = false; IsRunning = true; FileStream fs = null; try { Stopwatch stopwatch = new Stopwatch(); string blockImportFileName = Directory.EnumerateFiles(path, "GeoLiteCity-Blocks.csv").SingleOrDefault(); if (blockImportFileName == null) { IsRunning = false; if (OnComplete != null) { OnComplete.Invoke(this, new EventArgs()); } _progressText.Invoke("could not locate file 'GeoLiteCity-Blocks.csv', aborting."); return; } string cityImportFileName = Directory.EnumerateFiles(path, "GeoLiteCity-Location.csv").SingleOrDefault(); if (cityImportFileName == null) { IsRunning = false; if (OnComplete != null) { OnComplete.Invoke(this, new EventArgs()); } _progressText.Invoke("could not locate file 'GeoLiteCity-Location.csv', aborting."); return; } var geopIPBlocks = new ConcurrentBag <IBulkCopyItem>(); var geoIPCities = new ConcurrentBag <IBulkCopyItem>(); fs = File.OpenRead(blockImportFileName); var sr = new StreamReader(fs); _progressCallback.Invoke(0); stopwatch.Start(); bool hasInvalidRow = false; string[] lineBuffer = new string[1000]; while (!sr.EndOfStream) { if (_cancelImport) { IsRunning = false; if (OnComplete != null) { OnComplete.Invoke(this, new EventArgs()); } return; } if (stopwatch.ElapsedMilliseconds >= 100) { _progressCallback.Invoke((double)fs.Position / fs.Length); stopwatch.Restart(); } int itemsRead = 0; for (int i = 0; i < lineBuffer.Length; i++) { lineBuffer[i] = sr.ReadLine(); if (lineBuffer[i] == null) { break; } itemsRead++; } Parallel.For(0, itemsRead, i => { try { IBulkCopyItem geoBlockItem = ParseGeoIpBlock(lineBuffer[i]); if (geoBlockItem != null) { geopIPBlocks.Add(geoBlockItem); } } catch (Exception ex) { hasInvalidRow = true; _progressText.Invoke("Exception while parsing GeoIPBlock row: " + lineBuffer[i] + "\n" + ex.Message); } }); if (!ignoreInvalidRows && hasInvalidRow) { return; } } fs.Close(); fs = null; _progressText.Invoke(string.Format("Finished parsing {0} rows from GeoBlockIp import file.", geopIPBlocks.Count)); fs = File.OpenRead(cityImportFileName); sr = new StreamReader(fs); _progressCallback.Invoke(0); stopwatch.Restart(); while (!sr.EndOfStream) { if (_cancelImport) { IsRunning = false; if (OnComplete != null) { OnComplete.Invoke(this, new EventArgs()); } return; } if (stopwatch.ElapsedMilliseconds >= 100) { _progressCallback.Invoke((double)fs.Position / fs.Length); stopwatch.Restart(); } int itemsRead = 0; for (int i = 0; i < lineBuffer.Length; i++) { lineBuffer[i] = sr.ReadLine(); if (lineBuffer[i] == null) { break; } itemsRead++; } Parallel.For(0, itemsRead, i => { try { IBulkCopyItem geoIpCityItem = ParseGeoIpCity(lineBuffer[i]); if (geoIpCityItem != null) { geoIPCities.Add(geoIpCityItem); } } catch (Exception ex) { hasInvalidRow = true; _progressText.Invoke("Exception while parsing GeoIpCity row: " + lineBuffer[i] + "\n" + ex.Message); } }); if (!ignoreInvalidRows && hasInvalidRow) { return; } } fs.Close(); fs = null; stopwatch.Stop(); _progressText.Invoke(string.Format("Finished parsing {0} rows from GeoIPCity import file. Starting database import", geoIPCities.Count)); stopwatch.Restart(); _geoIpRepository = new GeoIPRepository(); _geoIpRepository.ImportGeoIPCitiesList(geopIPBlocks.ToList(), geoIPCities.ToList(), getGeoIpBlockColumnDefinitions(), getGeoIpCityColumnDefinitions(), d => _progressCallback(d)); stopwatch.Stop(); _progressText.Invoke("Database import completed after: " + stopwatch.Elapsed); } catch (Exception ex) { if (OnError != null) { OnError.Invoke(this, new ErrorEventArgs(ex)); } } finally { if (fs != null) { fs.Close(); } IsRunning = false; } if (OnComplete != null) { OnComplete.Invoke(this, new EventArgs()); } }
public void Start() { bool WriteError = false; byte[] buffer = new byte[1024 * 1024 * 50]; // 10MB buffer DateTime dtStart = DateTime.Now; var completeArgs = new FileCopyProgressCompleteArgs(); for (var i = 0; i < _Tasks.Count; i++) { var task = _Tasks[i]; completeArgs.Src = task.src; completeArgs.Dst = task.dst; if (!Directory.Exists(Path.GetDirectoryName(task.dst))) { try { Directory.CreateDirectory(Path.GetDirectoryName(task.dst)); } catch (Exception exp) { completeArgs.CompleteType = ProgressCompleteType.Error; completeArgs.ErrorCode = "500"; completeArgs.ErrorMessage = $"创建目标文件夹失败\r\n{exp}"; goto finished; } } OnProgressChanged?.Invoke(this, new FileCopyProgressArgs() { Src = task.src, Dst = task.dst, Progress = 0, TaskName = $"[{i+1}/{_Tasks.Count}]{Path.GetFileName(task.dst)}" }); FileStream source = null; try { source = new FileStream(task.src, FileMode.Open, FileAccess.Read); } catch (Exception exp) { completeArgs.CompleteType = ProgressCompleteType.Error; completeArgs.ErrorCode = "501"; completeArgs.ErrorMessage = $"打开源文件{Path.GetFileName(task.src)}失败\r\n{exp}"; goto finished; } { long fileLength = source.Length; FileStream dest = null; long totalBytes = 0; int currentBlockSize = 0; try { dest = new FileStream(task.dst, FileMode.CreateNew, FileAccess.Write); } catch (Exception exp) { completeArgs.CompleteType = ProgressCompleteType.Error; completeArgs.ErrorCode = "502"; completeArgs.ErrorMessage = $"创建目标文件{Path.GetFileName(task.src)}失败\r\n{exp}"; source.Close(); goto finished; } while (!_Cancel && (currentBlockSize = source.Read(buffer, 0, buffer.Length)) > 0) { totalBytes += currentBlockSize; var persentage = totalBytes * 100 / fileLength; try { dest.Write(buffer, 0, currentBlockSize); } catch (Exception exp) { WriteError = true; completeArgs.CompleteType = ProgressCompleteType.Error; completeArgs.ErrorCode = "503"; completeArgs.ErrorMessage = $"写入文件{Path.GetFileName(task.dst)}失败\r\n{exp}"; break; } OnProgressChanged?.Invoke(this, new FileCopyProgressArgs() { Src = task.src, Dst = task.dst, Progress = (int)persentage, TaskName = $"[{i + 1}/{_Tasks.Count}]{Path.GetFileName(task.dst)}", LeftInfo = $"{persentage}%", RightInfo = $"{FileSize.GetAutoSizeString(totalBytes)}/{FileSize.GetAutoSizeString(fileLength)}", }); } dest.Close(); } source.Close(); if (WriteError) { try { File.Delete(task.dst); } catch (Exception exp) { completeArgs.CompleteType = ProgressCompleteType.Error; completeArgs.ErrorCode = "504"; completeArgs.ErrorMessage = $"删除文件{Path.GetFileName(task.dst)}失败\r\n{exp}"; goto finished; } } if (_Cancel) { completeArgs.CompleteType = ProgressCompleteType.Cancel; try { File.Delete(task.dst); } catch (Exception exp) { completeArgs.CompleteType = ProgressCompleteType.Error; completeArgs.ErrorCode = "505"; completeArgs.ErrorMessage = $"删除目标文件{Path.GetFileName(task.dst)}失败\r\n{exp}"; goto finished; } } if (IsMove && !_Cancel && !WriteError) { try { File.Delete(task.src); } catch (Exception exp) { completeArgs.CompleteType = ProgressCompleteType.Error; completeArgs.ErrorCode = "506"; completeArgs.ErrorMessage = $"删除源文件{Path.GetFileName(task.src)}失败\r\n{exp}"; goto finished; } } if (!_Cancel && !WriteError) { completeArgs.CompleteType = ProgressCompleteType.Finish; completeArgs.ErrorCode = "000"; completeArgs.ErrorMessage = "操作成功"; } } finished: completeArgs.UsedTime = DateTime.Now - dtStart; OnComplete?.Invoke(this, completeArgs); }
public void OnKeyDown(Keys key) { if (key == Keys.PageUp && Main.IsOnServer()) { _mainScaleform.CallFunction("PAGE_UP"); } else if (key == Keys.PageDown && Main.IsOnServer()) { _mainScaleform.CallFunction("PAGE_DOWN"); } if (!IsFocused) { return; } if ((key == Keys.ShiftKey && _lastKey == Keys.Menu) || (key == Keys.Menu && _lastKey == Keys.ShiftKey)) { ActivateKeyboardLayout(1, 0); } _lastKey = key; if (key == Keys.Escape) { IsFocused = false; CurrentInput = ""; } var keyChar = GetCharFromKey(key, Game.IsKeyPressed(Keys.ShiftKey), false); if (keyChar.Length == 0) { return; } if (keyChar[0] == (char)8) { _mainScaleform.CallFunction("SET_FOCUS", 1, 2, "ALL"); _mainScaleform.CallFunction("SET_FOCUS", 2, 2, "ALL"); if (CurrentInput.Length > 0) { CurrentInput = CurrentInput.Substring(0, CurrentInput.Length - 1); _mainScaleform.CallFunction("ADD_TEXT", CurrentInput); } return; } if (keyChar[0] == (char)13) { _mainScaleform.CallFunction("ADD_TEXT", "ENTER"); if (OnComplete != null) { OnComplete.Invoke(this, EventArgs.Empty); } CurrentInput = ""; return; } var str = keyChar; CurrentInput += str; _mainScaleform.CallFunction("ADD_TEXT", str); }
public void Assign(OnComplete onComplete) => OnCompleted = onComplete;
internal static void Complete(_Level level) => OnComplete?.Invoke(level);
public void Unassign() => OnCompleted = null;
void GetAllowedToCheckInGroupTypeRole( OnComplete onComplete ) { ApplicationApi.GetGroupTypeRoleForGuid( Rock.Client.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_ALLOW_CHECK_IN_BY, delegate(System.Net.HttpStatusCode statusCode, string statusDescription, List<Rock.Client.GroupTypeRole> model ) { if ( Rock.Mobile.Network.Util.StatusInSuccessRange( statusCode ) == true && model != null && model.Count > 0 ) { TempAllowedCheckInByRole = model[ 0 ]; // Note: add more stuff here if you need. onComplete( true ); } // Allowed Check In By Role Failed else { onComplete( false ); } } ); }
/// <summary> /// Constructor. /// </summary> /// <param name="duration">Duration of the tween.</param> /// <param name="complete">Optional completion callback.</param> /// <param name="type">Tween type.</param> /// <param name="ease">Optional easer function.</param> protected Motion(float duration, OnComplete complete = null, uint type = 0, Easer ease = null) : base(duration, type, complete, ease) { }
void GetCanCheckInGroupTypeRole( OnComplete onComplete ) { ApplicationApi.GetGroupTypeRoleForGuid( Rock.Client.SystemGuid.GroupRole.GROUPROLE_KNOWN_RELATIONSHIPS_CAN_CHECK_IN, delegate(System.Net.HttpStatusCode statusCode, string statusDescription, List<Rock.Client.GroupTypeRole> model ) { if ( Rock.Mobile.Network.Util.StatusInSuccessRange( statusCode ) == true && model != null && model.Count > 0 ) { TempCanCheckInRole = model[ 0 ]; GetAllowedToCheckInGroupTypeRole( onComplete ); } // Can Check In Role Failed else { onComplete( false ); } } ); }
internal void Complete(UnityWebRequestAsyncOperation asyncOp) { Result = asyncOp; OnComplete?.Invoke(Result); }
void GetConfigTemplates( OnComplete onComplete ) { ConfigurationTemplate.DownloadConfigurationTemplates( delegate( List<Rock.Client.DefinedValue> model ) { if ( model != null ) { TempConfigurationTemplates = model; GetCampuses( onComplete ); } // Config Templates Failed else { onComplete( false ); } } ); }
public void SetConfigurations(AudioSource audioSource, OnComplete onCompleteCallback) { time = 0; this.audioSource = audioSource; this.onCompleteCallback = onCompleteCallback; }
void GetMaritalValues( OnComplete onComplete ) { ApplicationApi.GetDefinedValuesForDefinedType( Rock.Client.SystemGuid.DefinedType.PERSON_MARITAL_STATUS, delegate(System.Net.HttpStatusCode statusCode, string statusDescription, List<Rock.Client.DefinedValue> model ) { if( Rock.Mobile.Network.Util.StatusInSuccessRange( statusCode ) == true ) { TempMaritalStatus = model; GetSchoolGrades( onComplete ); } // Marital Status Failed else { onComplete( false ); } } ); }
protected void RaiseOnComplete() { OnComplete?.Invoke(this, new EventArgs()); }
public virtual void Run(params string[] arguments) { if (Stat == Status.Running) { this.Log("任务运行中...", LogLevel.Warn); return; } CheckIfSettingsCorrect(); #if !NET_CORE // 开启多线程支持 ServicePointManager.DefaultConnectionLimit = 1000; #endif InitComponent(arguments); Monitorable.IsExited = false; if (arguments.Contains("running-test")) { _scheduler.IsExited = true; return; } if (StartTime == DateTime.MinValue) { StartTime = DateTime.Now; } Stat = Status.Running; _realStat = Status.Running; while (Stat == Status.Running || Stat == Status.Stopped) { if (Stat == Status.Stopped) { _realStat = Status.Stopped; Thread.Sleep(50); continue; } Parallel.For(0, ThreadNum, new ParallelOptions { MaxDegreeOfParallelism = ThreadNum }, i => { int waitCount = 0; bool firstTask = false; var downloader = Downloader.Clone(); while (Stat == Status.Running) { Request request = Scheduler.Poll(); if (request == null) { if (waitCount > _waitCountLimit && ExitWhenComplete) { Stat = Status.Finished; _realStat = Status.Finished; _OnComplete(); OnComplete?.Invoke(); break; } // wait until new url added WaitNewUrl(ref waitCount); } else { waitCount = 0; try { Stopwatch sw = new Stopwatch(); ProcessRequest(sw, request, downloader); Thread.Sleep(Site.SleepTime); _OnSuccess(request); } catch (Exception e) { OnError(request); this.Log($"采集失败: {request.Url}.", LogLevel.Error, e); } finally { if (request.GetExtra(Request.Proxy) != null) { var statusCode = request.GetExtra(Request.StatusCode); Site.ReturnHttpProxy(request.GetExtra(Request.Proxy) as UseSpecifiedUriWebProxy, statusCode == null ? HttpStatusCode.Found : (HttpStatusCode)statusCode); } } if (!firstTask) { Thread.Sleep(3000); firstTask = true; } } } }); } FinishedTime = DateTime.Now; _realStat = Status.Exited; OnClose(); this.Log($"等待监控进程退出.", LogLevel.Info); _monitorTask.Wait(); OnClosing?.Invoke(); var msg = Stat == Status.Finished ? "结束采集" : "退出采集"; this.Log($"{msg}, 运行时间: {(FinishedTime - StartTime).TotalSeconds} 秒.", LogLevel.Info); }
public void Complete() { isActive = false; hasBeenCompleted = true; finishedAt = DateTime.Now; OnComplete.Raise(Name); }
public ReadBlockThunk() { OnDecodeComplete = _OnDecodeComplete; }
private void OnGameOver(GameData pGameData) { OnComplete?.Invoke(pGameData); }
public WriteThunk() { Result = new SignalFuture(); FlushOnComplete = _FlushOnComplete; }
private void CloseMe(bool userCanceled) { OnComplete?.Invoke(userCanceled, this._createTemplate, this._updateTemplate, null); }
private IEnumerator<object> PromptHelper(IEnumerator<object> task, OnComplete onComplete) { Start ts = new Start(task, TaskExecutionPolicy.RunAsBackgroundTask); yield return ts; ts.Future.RegisterOnComplete(onComplete); }
protected bool Equals(OnComplete other) { return(Equals(Source, other.Source)); }