public void Update() { ClearCases(); if (_curContext == null) { if (_started) { _out.Write(Content.root_message); } else { var country = _services.GetService <CountryController>().PlayerCountry; if (country != null) { var countryName = country.Name; var raceName = Content.ResourceManager.GetString("race_" + country.Kind.Id);; _out.WriteFormat(Content.hello_message, countryName, raceName); _started = true; } } OnStart.Invoke(); } else { _curContext.Update(); } }
void onStartCallback() { if (onStart != null) { onStart.Invoke(); } }
private void Start() { if (OnStart != null) { OnStart.Invoke(); } }
public override void iTweenPlay() { Hashtable ht = new Hashtable(); ht.Add("from", this.valueFrom); ht.Add("to", this.valueTo); ht.Add("time", this.tweenTime); ht.Add("delay", this.waitTime); ht.Add("looptype", this.loopType); ht.Add("easetype", this.easeType); ht.Add("onstart", (Action <object>)(newVal => { _onUpdate(this.valueFrom); if (onStart != null) { onStart.Invoke(); } })); ht.Add("onupdate", (Action <object>)(newVal => { _onUpdate((float)newVal); })); ht.Add("oncomplete", (Action <object>)(newVal => { if (onComplete != null) { onComplete.Invoke(); } })); ht.Add("ignoretimescale", ignoreTimescale); iTween.ValueTo(this.gameObject, ht); }
public void InvokeOnStart(object a_sender, IntEventArgs a_1intEventArgs) { if (OnStart != null) { OnStart.Invoke(a_sender, a_1intEventArgs); } }
private void ProcessMessage(AntMediaSignalingMessage msg) { switch (msg.command) { case "start": OnStart.Invoke(msg.streamId); break; case "takeConfiguration": if (msg.type == "offer") { OnOffer.Invoke(msg); } else if (msg.type == "answer") { OnAnswer.Invoke(msg); } break; case "takeCandidate": OnIceCandidate.Invoke(msg); break; case "error": OnSignalingError.Invoke(msg.definition); break; } }
public async Task Start() { if (OnStart != null) { await OnStart.Invoke(); } }
void Start() { NumberPending--; NumberInService++; Console.WriteLine($"{ClockTime}\t{GetType().Name}#{Index}\tStart. #Pending: {NumberPending}, #In-Service: {NumberInService}"); Schedule(Finish, TimeSpan.FromHours(Exponential.Sample(DefaultRS, 1 / HourlyServiceRate))); OnStart.Invoke(); }
public virtual bool OnEventStart() { if (EventStart != null) { EventStart.Invoke(); } return(_signHand.EventTryStart(this)); }
public async Task Start() { CaptureDisabled = false; if (OnStart != null) { await OnStart.Invoke(); } StateHasChanged(); }
/** * Play the transition from on to off. * @since 4.1.4 */ public override void TransitionOut() { if (gameObject.activeInHierarchy) { OnStart.Invoke(); StopAllCoroutines(); StartCoroutine(doTransitionOut()); } }
public static void start(OnVoid cb) { _starts.Invoke(() => { if (--_count > 0) { return; } cb(); }); }
public void GameStart() { Paused = false; Started = true; foreach (var component in components.ToArray()) { component.GameStart(); } if (OnStart != null) { OnStart.Invoke(); } }
public void SetSound(AudioClip clip, float volume) { this.audio.clip = this.clip = clip; this.audio.volume = volume; this.audio.Play(); if (OnStart != null) { OnStart.Invoke(this); } StartCoroutine("KillSound", clip.length); }
/// <summary> /// /// </summary> public void Start() { if (_started) { return; } _started = true; _timer = new Timer(Execute, true, StartInterval, Timeout.Infinite); if (null != OnStart) { OnStart.Invoke(this); } }
IEnumerator CoAnimation(Action <float> onUpdate, Action onComplete) { IsPlaying = true; if (Delay >= 0) { float delayStartTime = Time; while (Time - delayStartTime < Delay) { yield return(null); } } float endTime = Curve.keys[Curve.length - 1].time; Value = Curve.Evaluate(0); OnStart.Invoke(this); float startTime = Time; CurrentAnimationTime = 0; while (CurrentAnimationTime < Duration) { Value = Curve.Evaluate(endTime * CurrentAnimationTime / Duration); if (onUpdate != null) { onUpdate(Value); } this.OnUpdate.Invoke(this); yield return(null); CurrentAnimationTime = Time - startTime; } Value = Curve.Evaluate(endTime); if (onUpdate != null) { onUpdate(Value); } OnUpdate.Invoke(this); if (onComplete != null) { onComplete(); } OnComplete.Invoke(this); IsPlaying = false; currentCoroutine = null; }
public override void Start() { source.clip = clip; source.loop = loop; if (!source.isPlaying) { source.Play(); } if (OnStart != null) { OnStart.Invoke(); } if (!loop) { FreeSource(source.clip.length); } }
public void Start(TimeSpan time) { if (active) { return; } active = true; OnStart?.Invoke(); stopTimer = new Timer(time.TotalMilliseconds) { AutoReset = false, }; stopTimer.Elapsed += Stop; stopTimer.Start(); }
/// <inheritdoc /> public async Task StartAsync() { if (!IsInitialized) { await InitializeAsync(); } if (InitializationException != null) { _log.LogCritical(InitializationException, "EliteAPI could not be started"); OnError?.Invoke(this, InitializationException); await StopAsync(); return; } IsRunning = true; var delay = TimeSpan.FromMilliseconds(500); if (_codeConfig.TickFrequency != TimeSpan.Zero) { delay = _codeConfig.TickFrequency; } var task = Task.Run(async() => { _log.LogInformation("EliteAPI has started"); OnStart?.Invoke(this, EventArgs.Empty); if (_codeConfig.ProcessHistoricalJournals) { await ProcessHistoricalJournalFiles(_codeConfig.HistoricalJournalSpan); } while (IsRunning) { await DoTick(); await Task.Delay(delay); } OnStop?.Invoke(this, EventArgs.Empty); }); }
public void Start(IPEndPoint localIPEP, ushort bufferSize = 512) { _Cleanup(); LocalIPEP = localIPEP ?? throw new ArgumentNullException(nameof(localIPEP)); BufferSize = bufferSize < 64 ? throw new ArgumentOutOfRangeException(nameof(bufferSize)) : bufferSize; _isOpen = new ValueWrapper <bool>(true); _socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); _socket.Bind(localIPEP); _thread = new Thread(_ReceiveThread); _thread.Start(); LocalIPEP = (IPEndPoint)_socket.LocalEndPoint; OnStart?.Invoke(); }
public static async Task CSV(DataTable dt, string filename) { await Task.Yield(); OnStart?.Invoke(); using (StringWriter sw = new StringWriter()) { StringBuilder sb = new StringBuilder(); char c = ','; for (int i = 0; i < dt.Columns.Count; i++) { sb.Append(dt.Columns[i].Caption + c); } sb.Append("\r\n"); for (int i = 0; i < dt.Rows.Count; i++) { for (int j = 0; j < dt.Columns.Count; j++) { try { sb.Append(ConvertToSaveCell(dt.Rows[i][j])); OnRunning.Invoke(i * dt.Columns.Count + (j + 1), dt.Rows.Count * dt.Columns.Count); } catch { sb.Append(c); } } sb.Append("\r\n"); } sw.Write(Encoding.UTF8.GetString(new byte[] { (byte)0xEF, (byte)0xBB, (byte)0xBF })); sw.Write(sb); using (var fs = File.Open(filename, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite)) { using (StreamWriter ssw = new StreamWriter(fs)) { await ssw.WriteAsync(sb.ToString()); } } } OnStop?.Invoke(); }
void Update() { if (devContainer == null) { return; } if (!streaming && devContainer.newFrameAvailable && devContainer.pipe.ActiveProfile != null) { OnStart?.Invoke(devContainer.pipe.ActiveProfile); streaming = true; } if (streaming && devContainer.newFrameAvailable) { OnNewSample?.Invoke(devContainer.latestFrameSet); } meshRenderer.material.SetFloat("_PointSize", bodyghost.GetPointSize); meshRenderer.material.SetFloat("_UseDistance", bodyghost.GetScaleByDistance ? 1 : 0); }
/// <summary> /// 下载磁链接文件 /// </summary> /// <param name="metalink">磁链接文件</param> /// <param name="dir">下载目录</param> /// <returns>成功返回任务标识符,失败返回空</returns> public string AddMetalink(string metalink, string fileName = "", string dir = "") { try { string gid = Aria2cWarpper.AddMetalink(metalink, fileName, dir); if (!string.IsNullOrWhiteSpace(gid)) { Aria2cTask task = Aria2cWarpper.TellStatus(gid); OnStart?.Invoke(this, new Aria2cTaskEvent(task)); AddDownTask(task); } return(gid); } catch (Exception ex) { Console.WriteLine(ex); return(string.Empty); } }
public async Task <T> RunAction <T>(Func <ActionContext, Task <T> > action, [CallerMemberName] string name = null) { using (var context = new ActionContext(name, Sanitizers)) { try { if (context.IsRoot) { OnStart?.Invoke(context); } return(await action?.Invoke(context)); } catch (Exception ex) { throw HandleError(ex, context); } }; }
public List <PoreAnalyzeData> FindShapes(Bitmap bitmap) { Bitmap reversedbmp = ReverseBitmapColors(bitmap); BlobCounter blobCounter = new BlobCounter(reversedbmp); Blob[] blobs = blobCounter.GetObjects(reversedbmp, false); PoreAnalyzeData[] poreData = new PoreAnalyzeData[blobs.Length]; OnStart?.Invoke(this, blobs.Length); Parallel.For(0, blobs.Length, index => { var edgePoints = blobCounter.GetBlobsEdgePoints(blobs[index]); poreData[index] = new PoreAnalyzeData(blobs[index], ReverseBitmapColors(blobs[index].Image.ToManagedImage()), edgePoints); OnProgress?.Invoke(this, new EventArgs()); }); return(poreData.ToList()); }
public void AdjustedStart(int offsetMs) { if (CurrentState.CurrentPhase == TimerPhase.NotRunning) { TimeSpan AdjustedTimeSpan = new TimeSpan(0, 0, 0, 0, offsetMs); CurrentState.CurrentPhase = TimerPhase.Running; CurrentState.CurrentSplitIndex = 0; CurrentState.AttemptStarted = TimeStamp.CurrentDateTime; CurrentState.AdjustedStartTime = CurrentState.StartTimeWithOffset = TimeStamp.Now - CurrentState.Run.Offset - AdjustedTimeSpan; CurrentState.StartTime = TimeStamp.Now; CurrentState.TimePausedAt = CurrentState.Run.Offset; CurrentState.IsGameTimeInitialized = false; CurrentState.Run.AttemptCount++; CurrentState.Run.HasChanged = true; OnStart?.Invoke(this, null); } }
public async Task RunAction(Func <ActionContext, Task> action, [CallerMemberName] string name = null, string contextGroupName = "default") { using (var context = new ActionContext(contextGroupName, name, Settings, Sanitizers)) { try { if (context.IsRoot) { OnStart?.Invoke(context); } await action?.Invoke(context); } catch (Exception ex) { throw HandleError(ex, context); } }; }
public void RunAction(Action <ActionContext> action, [CallerMemberName] string name = null) { using (var context = new ActionContext(name, Sanitizers)) { try { if (context.IsRoot) { OnStart?.Invoke(context); } action?.Invoke(context); } catch (Exception ex) { throw HandleError(ex, context); } }; }
public IActionContext Create([CallerMemberName] string name = null, string contextGroupName = "default") { var context = new ActionContext(contextGroupName, name, Settings, Sanitizers); context.State.SetParam("RunnerType", this.GetType().Name); if (context.Info.IsRoot) { OnStart?.Invoke(context); } context.OnDispose = c => { OnEnd?.Invoke(c); }; return(context); }
/// <summary> /// 添加下载任务 /// </summary> /// <param name="uri">下载地址</param> /// <param name="fileName">输出文件名</param> /// <param name="dir">下载文件夹</param> /// <param name="taskOptions">下载任务选项</param> /// <returns>成功返回任务标识符,失败返回空</returns> public string AddUri(string uri, string fileName = "", string dir = "", List <Dictionary <string, string> > taskOptions = null) { try { string gid = Aria2cWarpper.AddUri(uri, fileName, dir, taskOptions); if (!string.IsNullOrWhiteSpace(gid)) { Aria2cTask task = Aria2cWarpper.TellStatus(gid); OnStart?.Invoke(this, new Aria2cTaskEvent(task)); AddDownTask(task); } return(gid); } catch (Exception ex) { Console.WriteLine(ex); return(string.Empty); } }