public void OnComplete() { var pureMatrix = matrix.Clone(); var pages = PageList.Select(page => new SpiderNs.Page() { ID = page.id, Uri = page.url, StatusCode = page.statusCode }).ToList(); var purePages = pages.Where(a => a.StatusCode == System.Net.HttpStatusCode.OK).ToList(); for (int i = pureMatrix.ColumnCount - 1; i >= 0; i--) { if (pages[i].StatusCode != System.Net.HttpStatusCode.OK) { pureMatrix = pureMatrix.RemoveColumn(i); pureMatrix = pureMatrix.RemoveRow(i); } } pureMatrix = pureMatrix.InsertColumn(pureMatrix.ColumnCount, Vector <double> .Build.Dense(pureMatrix.RowCount, 1)); pureMatrix = pureMatrix.InsertRow(pureMatrix.RowCount, Vector <double> .Build.Dense(pureMatrix.ColumnCount, 1)); var colsSum = pureMatrix.ColumnSums(); var outLoopResult = Parallel.For(0, pureMatrix.ColumnCount, i => { var colSum = colsSum[i]; var inLoopResult = Parallel.For(0, pureMatrix.RowCount, j => { pureMatrix[j, i] /= colSum; }); while (!inLoopResult.IsCompleted) { Thread.Sleep(1); } }); while (!outLoopResult.IsCompleted) { Thread.Sleep(1); } var m = (Matrix <double> .Build.DiagonalIdentity(pureMatrix.RowCount, pureMatrix.ColumnCount) - pureMatrix); var scoresKernel = m.Kernel(); var scoresVector = scoresKernel[0]; scoresVector = scoresVector.SubVector(0, scoresVector.Count - 1); for (int i = 0; i < scoresVector.Count; i++) { var pageIndex = pages.IndexOf(pages.Find(page => purePages[i].ID == page.ID)); pages[pageIndex].Score = Math.Abs(scoresVector[i]); } SpiderCompleteEventArgs eventArgs = new SpiderCompleteEventArgs(matrix, pages); Complete?.Invoke(this, eventArgs); }
private async void button2_Click(object sender, EventArgs e) { Complete += THP_Complete; SaveFileDialog save = new SaveFileDialog { Filter = "mp4 file (*.mp4)|*.mp4|All files (*.*)|*.*", FilterIndex = 1, RestoreDirectory = true, InitialDirectory = Directory.GetCurrentDirectory(), Title = "Save the new mp4 file.", FileName = Path.GetFileNameWithoutExtension(Properties.Settings.Default.thp_video) }; string outfile = ""; if (save.ShowDialog() == DialogResult.OK) { outfile = save.FileName; } var inputFile = new MediaFile(Properties.Settings.Default.thp_video); var outFile = new MediaFile(outfile); if (!File.Exists(Properties.Settings.Default.ffmpeg_path)) { File.WriteAllBytes("ffmpeg.exe", Properties.Resources.ffmpeg); } var ffmpeg = new Engine(Properties.Settings.Default.ffmpeg_path); await ffmpeg.ConvertAsync(inputFile, outFile); Complete?.Invoke(); button2.Hide(); File.Delete("ffmpeg.exe"); return; }
public async void Run(Stream inputStream) { //Console.WriteLine("[{0}] is handling {1}", Thread.CurrentThread.ManagedThreadId, Name); if (!IsComputing) { IsComputing = true; InputStream = inputStream; InputStream.Position = 0; var bytes = await Algorithm.ComputeHashAsync(InputStream); StringBuilder builder = new StringBuilder(); for (int i = 0; i < bytes.Length; i++) { builder.Append(bytes[i].ToString("x2")); } OutString = builder.ToString().ToUpper(); InputStream.Position = 0; if (Complete != null) { Complete.Invoke(); } IsComputing = false; //Console.WriteLine("[{0}] is ended.", Thread.CurrentThread.ManagedThreadId); } }
public sealed override void OnStep() { Progress++; if (Progress >= Duration) { Step?.Invoke(this, new TweenEventArgs(TweeningFunction(1))); } else { Step?.Invoke(this, new TweenEventArgs(TweeningFunction((double)Progress / Duration))); } if (_sentinels.TryGetValue(Progress, out var sentinels)) { foreach (var sentinel in sentinels) { sentinel.Invoke(); } } if (Progress >= Duration) { Complete?.Invoke(this, new EventArgs()); Destroy(); } }
public void continueRegistry() { var path = Path.Combine(installLocation, "ChessInstaller.exe"); setUpdate("Registering web protocol"); var main = Registry.CurrentUser.CreateSubKey("Software"); var cls = main.CreateSubKey("Classes"); var key = cls.CreateSubKey("chess", true); key.SetValue("", "URL:chess Protocol"); key.SetValue("URL Protocol", ""); var keyShell = key.CreateSubKey("shell"); var keyOpen = keyShell.CreateSubKey("open"); var keyCom = keyOpen.CreateSubKey("command"); keyCom.SetValue("", $"\"{path}\" \"%1\" \"%2\" \"%3\" \"%4\" \"%5\" \"%6\" \"%7\" \"%8\" \"%9\""); setUpdate("Creating empty registry"); var empty = Registry.CurrentUser.CreateSubKey("CheAle14"); var chess = empty.CreateSubKey("ChessClient"); chess.SetValue("", path); chess.SetValue("InstalledOn", DateTime.Now.ToString()); chess.SetValue("Version", cVersion.ToString()); chess.SetValue("Token", getToken()); setUpdate("Complete!"); if (MessageBox.Show("In order to use this client, you must use the hyperlinks at the Chess Online webpage to open it.\r\n" + "Click OK to navigate to that webpage.", "Installation Complete", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK) { System.Diagnostics.Process.Start("https://ml-api.uk.ms/chess/online"); } Complete?.Invoke(this, null); }
protected override void ThreadRun() { productImage = ProductImage.Get(TaskSchedule.PlayerAccountId); if (productImage != null) { productImage.Status = 1; HttpRequest httpRequest = new HttpRequest(productImage.Url); try { WriteLog($"开始下载图片--{productImage.Url}"); Image image = httpRequest.GetImage(); var imagePath = createImagepath(); image.Save($"{imagePath}/{productImage.Asin}_{productImage.Number}.tbi", ImageFormat.Jpeg); ImageHelper.JoinImage($"{imagePath}/{productImage.Asin}_{productImage.Number}.tbi", Environment.CurrentDirectory + "\\Config\\shuiyin.png", "C"); WriteLog($"{productImage.Asin}_{productImage.Number}商品图片下载成功", Core.ConsoleLogStatus.Success); Complete?.Invoke(null, productImage, null, this); } catch { TaskSchedule.RunDateTime = DateTime.Now.AddMinutes(1).GetTimestamp(); } } else { Complete(null, null, null, this); return; } }
protected virtual void OnComplete(EventArgs e) { if (Complete != null) { Complete.Invoke(this, e); } }
public void Anim() { if (To != null) { moveAnimX.From = From.X; moveAnimY.From = From.Y; moveAnimX.To = To.X; moveAnimY.To = To.Y; if (Math.Abs((originPoint.X - To.X)) > Math.Abs((originPoint.Y - To.Y))) { moveAnimX.Completed += (s, e) => { Complete?.Invoke(this, new EventArgs()); }; } else { moveAnimY.Completed += (s, e) => { Complete?.Invoke(this, new EventArgs()); }; } transform.BeginAnimation(TranslateTransform.XProperty, moveAnimX); transform.BeginAnimation(TranslateTransform.YProperty, moveAnimY); } }
/// <summary> /// Releases a lease on the queue. /// </summary> void Release() { if (Interlocked.Decrement(ref leases) == 0) { Complete?.Invoke(this, EventArgs.Empty); } }
private void downloadCallback(string url, string filename, object obj) { if (Complete != null) { Complete.Invoke(null, Tuple.Create(url, filename, jobs[(int)obj].Item2)); } lock (add_lock) { remain_contents--; if (remain_contents == 0) { DownloadComplete.Invoke(null, null); } } download_file_count[(int)obj]++; if (download_file_count[(int)obj] == file_count[(int)obj]) { if (CompleteGroup != null) { CompleteGroup.Invoke(null, Tuple.Create("", jobs[(int)obj].Item2)); } } }
private void OnComplete(Fallible <T> value) { valueChecker.Dispose(); Status = FetchStatus.Complete; result = value; Complete?.Invoke(this, new EventArgs <Fallible <T> >(value)); }
/// <summary> /// Raises event 'Complete' /// </summary> protected virtual void OnComplete() { if (Complete != null) { Complete.Invoke(this, System.EventArgs.Empty); } }
/// <summary> /// Executes the specified task action. /// </summary> /// <param name="taskAction">The task action.</param> internal void Execute(Action <CancellationToken> taskAction) { task = Task.Run(() => { try { IsRunning = true; taskAction(cancelSource.Token); } catch (OperationCanceledException) { IsCanceled = true; } catch (AggregateException ae) { ae.Handle(ex => { if (ex is TaskCanceledException) { IsCanceled = true; return(true); } OnException(ex); return(true); }); } catch (Exception ex) { OnException(ex); } finally { IsRunning = false; task = null; Complete?.Invoke(this, EventArgs.Empty); } }, cancelSource.Token); }
private void LiveDisplayGrab() { while (isRealDisplay) { try { int ticketCount = System.Environment.TickCount; HObject ho_OutputImage = null; ho_OutputImage = SafeAsyncGrabImage(); HalImage8Grey image = new HalImage8Grey(ref ho_OutputImage); int triggerNumber = System.Environment.TickCount; HalCompleteEventArgs eventArgs = new HalCompleteEventArgs(ticketCount, triggerNumber, image); Complete?.Invoke(this, eventArgs); // Console.WriteLine("Grab one Image"); } catch (Exception ex) { isRealDisplay = false; Console.WriteLine(ex.ToString()); //throw ex; } } }
public void Run()//object { object result = taskBody(); Complete?.Invoke(this, result); //return result; }
private void Do() { Task.Run(() => { Thread.Sleep(1000); _value = true; Complete?.Invoke(_value); }); }
// rewarded video public void DidComplete() { Complete?.Invoke(this, EventArgs.Empty); if (Delegate != null) { DelegateR.DidComplete(); } }
/// <summary> /// Invoked by inherited flight tasks when they determine that the FlightTask is complete. /// </summary> protected void InvokeComplete() { Assert.AreEqual(State, FlightTaskState.Active, "Attempted to complete inactive FlightTask."); State = FlightTaskState.Complete; Complete?.Invoke(this); Invalidate(); }
internal void Run() { async Task wrappedGhostThreadFunction() { try { if (IsHaveReturn) { var x = await(dynamic) Method.Invoke(Controller, Args); if (x is Result xres) { Result = xres; Result.Id = this.Id; } else { Result = new Result(x) { Id = this.Id }; } Complete?.Invoke(Result); } else { await(Task) Method.Invoke(Controller, Args); } } catch (Exception er) { IsError = true; Error = er; if (IsHaveReturn) { Complete?.Invoke(GetExceptionResult(er, this.Id)); } if (PushException(er)) { Log.Error($"Cmd:{Cmd} Error:\r\n{Error}", er); } } finally { IsOver = true; AsyncUser.RemoveAsyncCall(Id); } } _fiber = new Fiber(); _fiber.SetAction(wrappedGhostThreadFunction); _fiber.Start(); }
private async Task ExecuteAsync(WKHtmltopdfParameters parameters, CancellationToken cancellationToken = default) { var wkhtmltopdfProcess = new WKHtmltopdfProcess(); wkhtmltopdfProcess.Progress += (e) => Progress?.Invoke(this, e); wkhtmltopdfProcess.Completed += (e) => Complete?.Invoke(this, e); wkhtmltopdfProcess.Error += (e) => Error?.Invoke(this, e); wkhtmltopdfProcess.Data += (e) => Data?.Invoke(this, e); await wkhtmltopdfProcess.ExecuteAsync(parameters, _wkhtmltopdfPath, cancellationToken); }
private void OnComplete() { Root .DOScaleX(0, 0.5f) .OnComplete(() => { Complete?.Invoke(this); onComplete?.Invoke(); }); }
private void Start() { _onColorChange = UpdateColor; _onColorChange(Color.green); // SingleCastExample(); MultiCastExample(); _onComplete?.Invoke(); }
private void OnCompleteButtonPointerUp() { try { Complete?.Invoke(); this.completeButton.Active = false; } catch (GameplayException exception) { UiErrorFrame.Instance.Push(exception.Message); } }
public EditSectionPageViewModel(ISectionsStorage sectionsStorage, Section section) { this.sectionsStorage = sectionsStorage; this.section = section; Name = section.Name; AddNewSectionCommand = new RelayCommand(() => { section.Name = Name; sectionsStorage.Save(); Complete?.Invoke(this, EventArgs.Empty); }); }
public void Run() { async Task wrappedGhostThreadFunction() { try { if (IsHaveReturn) { var res = await(dynamic) Method.Invoke(Obj, Args); if (res is Result xres) { Result = xres; } else { Result = new Result(res); } Result.Id = this.Id; Complete?.Invoke(Result); } else { await(Task) Method.Invoke(Obj, Args); } } catch (Exception er) { IsError = true; Error = er; if (IsHaveReturn) { Complete?.Invoke(GetExceptionResult(er, Id)); } if (PushException(er)) { Log.Error($"Cmd:{Cmd} Error:\r\n {Error}"); } } finally { IsOver = true; CCloudClient.RemoveAsyncCall(Id); } } _fiber = new Fiber(); _fiber.SetAction(wrappedGhostThreadFunction); _fiber.Start(); }
// Start is called before the first frame update void Start() { if (!Ready) { bool x = false; //Gets song assets Addressables.LoadAssetsAsync <Song>("Song", null).Completed += objs => { foreach (Song song in objs.Result) { Debug.Log($"Found song {song.songName}"); Songs.Add(song); } if (x) { Ready = true; Complete.Invoke(); } else { x = true; } }; //Gets AudioClips for menu music Addressables.LoadAssetsAsync <AudioClip>("MenuAudio", null).Completed += objs => { foreach (AudioClip aC in objs.Result) { MenuAudioClips.Add(aC); } if (x) { Ready = true; Complete.Invoke(); } else { x = true; } }; } //foreach (FileInfo fI in new DirectoryInfo(Path.Combine(Application.dataPath, "Resources", "songdata")).GetFiles("*.songdata")) //{ // StreamReader sR = new StreamReader(fI.OpenRead()); // Song song = new Song(sR.ReadToEnd()); // Songs.Add(song); // song.Log(); //} }
private void TestComplete(object sender, IOTaskCompleteEventArgs <SocketConnectTask> e) { e.Task.Completed -= TestComplete; if (e.Task.Exception == null) { Succeeded = e.Task.Socket.Connected; } Complete?.Invoke(this, EventArgs.Empty); socket.Destroy(); }
private IEnumerator PlayCompleteTask() { var temp = DicPool.Take(); var rank = new List <List <Pice> >(); var r1 = new List <Pice>(); r1.Add(lastDragPice); rank.Add(r1); temp[lastDragPice] = true; var next = new List <Pice>(); var last = r1; here: foreach (var pice in last) { foreach (var linking in pice.linkingList) { var nextPice = linking.pice; if (temp.ContainsKey(nextPice) && temp[nextPice]) { continue; } next.Add(nextPice); temp[nextPice] = true; } } if (next.Count > 0) { rank.Add(next); last = next; next = new List <Pice>(); goto here; } DicPool.Put(temp); AudioManager.PlaySe("level-complete-wave"); foreach (var list in rank) { foreach (var pice in list) { pice.Flash(); } yield return(new WaitForSeconds(0.15f)); } yield return(new WaitForSeconds(0.15f)); AudioManager.PlaySe("level-complete"); Complete?.Invoke(); }
/// <summary> /// Handles the command provided to the method, will update the DbSet based on the EntitySet provided in the command. /// This overload allows to supply own transaction reference. /// </summary> /// <param name="cmd"></param> /// <param name="tx"></param> /// <returns></returns> public UpdateEntityCommand <T> Handle(UpdateEntityCommand <T> cmd, DbContextTransaction tx) { var item = db.Set(cmd.EntityType).Find(cmd.Id); if (item == null) { throw new NullReferenceException("Resource not found"); } var version = DefaultVersion; try { var original = UpdateEntity(cmd, item); version = UpdateVersion(item as IHaveVersion, DefaultVersion); BeforeSave?.Invoke(this, new BeforeSaveEventArgs <T, TContext> { Context = db, Command = cmd, Original = original.From, Version = version }); db.SaveChanges(); tx.Commit(); return(cmd); } catch (DbEntityValidationException ex) { tx.Rollback(); DbEntityValidationException?.Invoke(this, new DbEntityValidationExceptionEventArgs <T>(cmd, ex, version)); throw; } catch (Exception ex) { tx.Rollback(); Exception?.Invoke(this, new ExceptionEventArgs <T>(cmd, ex, version)); throw; } finally { Complete?.Invoke(this, new EntityUpdatedEventArgs <T> { Command = cmd, Version = version }); } }
void IYieldFrame.Update(float delta, uint frameCount) { _time -= delta; Value01 = 1f - Mathf.Clamp01(_time / _seconds); if (ProgressChanged != null) { ProgressChanged.Invoke(Value01); } if (!keepWaiting) { if (Complete != null) { Complete.Invoke(); } } }