protected void InvokeStatusChanged() { if (StatusChanged != null) { StatusChanged.Invoke(this, new EventArgs()); } }
public void ResumeLoggingIfApplicable() { CheckDisposed(); object loggingEnabled; if (ApplicationData.Current.LocalSettings.Values.TryGetValue(LOGFILEGIEN_BEFORE_SUSPEND_SETTING_KEY_NAME, out loggingEnabled) == false) { ApplicationData.Current.LocalSettings.Values[LOGGING_ENABLED_SETTING_KEY_NAME] = true; loggingEnabled = ApplicationData.Current.LocalSettings.Values[LOGGING_ENABLED_SETTING_KEY_NAME]; } if (loggingEnabled is bool && (bool)loggingEnabled == true) { StartLogging(); } object LogFileGeneratedBeforeSuspendObject; if (ApplicationData.Current.LocalSettings.Values.TryGetValue(LOGFILEGIEN_BEFORE_SUSPEND_SETTING_KEY_NAME, out LogFileGeneratedBeforeSuspendObject) && LogFileGeneratedBeforeSuspendObject != null && LogFileGeneratedBeforeSuspendObject is string) { if (StatusChanged != null) { StatusChanged.Invoke(this, new FileLogEventArgs(FileLogEventType.LogFileGeneratedAtSuspend, (string)LogFileGeneratedBeforeSuspendObject)); } ApplicationData.Current.LocalSettings.Values[LOGFILEGIEN_BEFORE_SUSPEND_SETTING_KEY_NAME] = null; } }
private void UpdateStatus(string msg) { if (StatusChanged != null) { StatusChanged.Invoke(msg); } }
public void ChangeStatus(string status) { if (StatusChanged != null) { StatusChanged.Invoke(status); } }
/// <summary> /// Toggle the enabled/disabled status of logging. /// </summary> /// <returns>True if the resulting new status is enabled, else false for disabled.</returns> public bool ToggleLoggingEnabledDisabled() { CheckDisposed(); IsBusy = true; try { bool enabled; if (session != null) { session.Dispose(); session = null; ApplicationData.Current.LocalSettings.Values["LoggingEnabled"] = false; enabled = false; } else { StartLogging(); ApplicationData.Current.LocalSettings.Values["LoggingEnabled"] = true; enabled = true; } if (StatusChanged != null) { StatusChanged.Invoke(this, new LoggingScenarioEventArgs(enabled)); } return(enabled); } finally { IsBusy = false; } }
protected void StatusOnChanged(PedidoEventArgs e) { if (StatusChanged != null) { StatusChanged.Invoke(this, e); } }
/// <summary> /// This is called when the app is either resuming or starting. /// It will enable logging if the app has never been started before /// or if logging had been enabled the last time the app was running. /// </summary> public void ResumeLoggingIfApplicable() { CheckDisposed(); object loggingEnabled; if (ApplicationData.Current.LocalSettings.Values.TryGetValue(LOGGING_ENABLED_SETTING_KEY_NAME, out loggingEnabled) == false) { ApplicationData.Current.LocalSettings.Values[LOGGING_ENABLED_SETTING_KEY_NAME] = true; loggingEnabled = ApplicationData.Current.LocalSettings.Values[LOGGING_ENABLED_SETTING_KEY_NAME]; } if (loggingEnabled is bool && (bool)loggingEnabled == true) { StartLogging(); } // When the sample suspends, it retains state as to whether or not it had // generated a new log file at the last suspension. This allows any // UI to be updated on resume to reflect that fact. object LogFileGeneratedBeforeSuspendObject; if (ApplicationData.Current.LocalSettings.Values.TryGetValue(LOGFILEGEN_BEFORE_SUSPEND_SETTING_KEY_NAME, out LogFileGeneratedBeforeSuspendObject) && LogFileGeneratedBeforeSuspendObject != null && LogFileGeneratedBeforeSuspendObject is string) { if (StatusChanged != null) { StatusChanged.Invoke(this, new LoggingScenarioEventArgs(LoggingScenarioEventType.LogFileGeneratedAtSuspend, (string)LogFileGeneratedBeforeSuspendObject)); } ApplicationData.Current.LocalSettings.Values[LOGFILEGEN_BEFORE_SUSPEND_SETTING_KEY_NAME] = null; } }
protected virtual void OnStatusChanged() { if (StatusChanged != null) { StatusChanged.Invoke(this, EventArgs.Empty); } }
public void AddCode(string key, string status) { var existed = _codes.Find(item => item.Code == key); if (existed != null) { existed.LastEditTime = GetTime(); existed.Status = status; if (StatusChanged != null) { StatusChanged.Invoke(null, new CodeInfoEventArgs { Code = existed.Code, Status = status }); } } else { _codes.Add(new CodeInfo { Code = key, Status = status, LastEditTime = GetTime() }); } var sorted = _codes.OrderByDescending(item => item.LastEditTime).ToList(); _codes = sorted; CheckTooMuchCodes(); }
private void OnModuleFileChanged(FileSystemWatcher w) { this.Status = this.CheckItemStatus(); if (StatusChanged != null) { StatusChanged.Invoke(this, new ModuleStatusEventArgs(this.Status)); } }
public static void RaiseStatusEvent(string msg) { //Console.WriteLine(_statusMessage); if (StatusChanged != null) { StatusChanged.Invoke(null, new StatusChangedEventArgs(msg)); } }
private async void LogFileGenerateHandler(IFileLoggingSession sender, LogFileGeneratedEventArgs args) { StorageFolder sampleAppDefinedLogFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(APP_LOG_FILE_FOLDER_NAME, CreationCollisionOption.OpenIfExists); string newLogFileName = "Log-" + GetTimeStamp() + ".etl"; await args.File.MoveAsync(sampleAppDefinedLogFolder, newLogFileName); if (IsPreparingForSuspend == false) { if (StatusChanged != null) { string newLogFileFullPathName = System.IO.Path.Combine(sampleAppDefinedLogFolder.Path, newLogFileName); StatusChanged.Invoke(this, new FileLogEventArgs(FileLogEventType.LogFileGenerated, newLogFileFullPathName)); } } }
/// <summary> /// This handler is called by the FileLoggingSession instance when a log /// file reaches a size of 256MB. When FileLoggingSession calls this handler, /// it's effectively giving the developer a chance to own the log file. /// </summary> /// <param name="sender">The IFileLoggingSession to the session which has generated a new file.</param> /// <param name="args">The LogFileGeneratedEventArgs instance which contains a StorageFile field LogFileGeneratedEventArgs.File representing the new log file.</param> private async void LogFileGeneratedHandler(IFileLoggingSession sender, LogFileGeneratedEventArgs args) { LogFileGeneratedCount++; StorageFolder sampleAppDefinedLogFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(OUR_SAMPLE_APP_LOG_FILE_FOLDER_NAME, CreationCollisionOption.OpenIfExists); string newLogFileName = string.Format("{0}-{1}.etl", LOG_FILE_BASE_FILE_NAME, GetTimeStamp()); await args.File.MoveAsync(sampleAppDefinedLogFolder, newLogFileName); if (IsPreparingForSuspend == false) { if (StatusChanged != null) { string newLogFileFullPathName = System.IO.Path.Combine(sampleAppDefinedLogFolder.Path, newLogFileName); StatusChanged.Invoke(this, new LoggingScenarioEventArgs(LoggingScenarioEventType.LogFileGenerated, newLogFileFullPathName)); } } }
public void SetStatus(Status status, TargetedAction action) { Current = status; if (Current == Status.None && _statusEffect != null) { Destroy(_statusEffect.gameObject); } else if (action != null) { _statusEffect = action; _statusEffect.SetReciever(_character); } if (StatusChanged != null) { StatusChanged.Invoke(new StatusChangeEvent(_character, status)); } }
public async Task <bool> ToggleLoggingEnabledDisabledAsync() { CheckDisposed(); IsBusy = true; try { bool enabled; if (session != null) { string finalLogFilePath = await CloseSessionSaveFinalLogFile(); session.Dispose(); session = null; if (StatusChanged != null) { StatusChanged.Invoke(this, new FileLogEventArgs(FileLogEventType.LogFileGeneratedAtDisable, finalLogFilePath)); } ApplicationData.Current.LocalSettings.Values[LOGGING_ENABLED_SETTING_KEY_NAME] = false; enabled = false; } else { StartLogging(); ApplicationData.Current.LocalSettings.Values[LOGGING_ENABLED_SETTING_KEY_NAME] = true; enabled = true; } if (StatusChanged != null) { StatusChanged.Invoke(this, new FileLogEventArgs(enabled)); } return(enabled); } finally { IsBusy = false; } }
} // ShowSettingsEditor #region Events protected virtual void OnStatusChanged(object sender, ListStatusChangedEventArgs e) { StatusChanged?.Invoke(sender, e); } // OnStatusChanged
public bool PlayerControl(Keys keyData) { switch (keyData) { case Keys.Left: if (PositionX > 50) { PositionX -= 10; changePosition = true; } else { changePosition = false; } break; case Keys.Up: if (PositionY > 45) { PositionY -= 10; changePosition = true; } else { changePosition = false; } break; case Keys.Right: if (PositionX + 50 < (form.ClientSize.Width - 50)) { PositionX += 10; changePosition = true; } else { changePosition = false; } break; case Keys.Down: if (PositionY + 50 < (form.ClientSize.Height - 45)) { PositionY += 10; changePosition = true; } else { changePosition = false; } break; case Keys.Escape: default: changePosition = false; break; } if (changedLocalPLayer != null) { changedLocalPLayer.Invoke(); } if (changePosition) { SendChange(); } return(changePosition); }
protected virtual void OnStatusChanged(EventArgs args) { StatusChanged?.Invoke(this, args); }
private void OnStatusChanged() { StatusChanged?.Invoke(this, EventArgs.Empty); }
private void ConnectionStatusChanged(object sender, string s) { StatusChanged?.Invoke(this, s); }
public void SendEventMessage(LogAdpType adapterType, string message) { StatusChanged?.Invoke(adapterType, message); }
/// <summary> /// Raises <see cref="StatusChanged"/> event. /// </summary> protected void OnStatusChanged() { StatusChanged?.Invoke(this); OnWorkerResourcesChanged(WorkerResource.Status, increased: Status == WorkerNodeStatus.Running); }
/// <summary> /// Evento que notifica a mudança de status /// </summary> /// <param name="_par_objEventArgs">Argumentos do evento</param> public static void OnStatusChanged(StatusChangedEventArgs _par_objEventArgs) { StatusChanged?.Invoke(null, _par_objEventArgs); }
public override void Stop() { StatusChanged.Invoke(this, false); _dumpFile = null; }
// This is called when we want to raise the StatusChanged event public static void OnStatusChanged(string status) { StatusChanged.Invoke(status); }
public override void Start() { _dumpFile = new System.IO.StreamReader(_filePath); StatusChanged.Invoke(this, true); }
/// <summary> /// The logging scenario. Log messages in a loop until 3 log files are created. /// </summary> /// <returns>The task.</returns> public async Task DoScenarioAsync() { CheckDisposed(); IsBusy = true; try { await Task.Run(async() => { const int NUMBER_OF_LOG_FILES_TO_GENERATE = 3; int messageIndex = 0; int lastDelay = 0; int lastAppError = 0; int startFileCount = LogFileGeneratedCount; // // Log large messages until the current log file hits the maximum size. // When the current log file reaches its maximum size, LogFileGeneratedHandler // will be called. // while (LogFileGeneratedCount - startFileCount < NUMBER_OF_LOG_FILES_TO_GENERATE) { try { // Since the channel is added to the session at level Warning, // the following is logged because it is logged at level LoggingLevel.Critical. channel.LogMessage( string.Format("Message={0}: Lorem ipsum dolor sit amet, consectetur adipiscing elit. In ligula nisi, vehicula nec eleifend vel, rutrum non dolor. Vestibulum ante ipsum " + "primis in faucibus orci luctus et ultrices posuere cubilia Curae; Curabitur elementum scelerisque accumsan. In hac habitasse platea dictumst.", ++messageIndex), LoggingLevel.Critical); // Since the channel is added to the session at level Warning, // the following is *not* logged because it is logged at LoggingLevel.Information. channel.LogMessage( string.Format("Message={0}: Lorem ipsum dolor sit amet, consectetur adipiscing elit. In ligula nisi, vehicula nec eleifend vel, rutrum non dolor. Vestibulum ante ipsum " + "primis in faucibus orci luctus et ultrices posuere cubilia Curae; Curabitur elementum scelerisque accumsan. In hac habitasse platea dictumst.", ++messageIndex), LoggingLevel.Information); int value = 1000000; // one million, 7 digits, 4-bytes as an int, 14 bytes as a wide character string. channel.LogMessage("Value #" + (++messageIndex).ToString() + " " + value.ToString(), LoggingLevel.Critical); // value is logged as 14 byte wide character string. channel.LogValuePair("Value #" + (++messageIndex).ToString(), value, LoggingLevel.Critical); // value is logged as a 4-byte integer. // // Pause every once in a while to simulate application // activity outside of logging. // if (messageIndex - lastDelay > 100) { lastDelay = messageIndex; await Task.Delay(10); } // // Every once in a while, simulate an application error // which causes the app to save the current snapshot // of logging events in memory to a disk ETL file. // if (messageIndex - lastAppError >= 25000) { lastAppError = messageIndex; // Before simulating an application error, demonstrate LoggingActivity. // A LoggingActivity outputs a pair of begin and end messages to the channel. using (new LoggingActivity("Add two numbers.", channel, LoggingLevel.Critical)) { int oneNumber = 100; int anotherNumber = 200; int total = oneNumber + anotherNumber; channel.LogMessage(string.Format("Message={0}: The result of adding two numbers: {1}", ++messageIndex, total), LoggingLevel.Critical); } // The LoggingActivity instance will log the second message at this scope exit. // Simulate an application error. throw new AppException("Some bad app error occurred."); } } catch (AppException e) { // Log the exception string. channel.LogMessage("Exception occurrred: " + e.ToString(), LoggingLevel.Error); // Save the memory log buffer to file. Task <string> op = SaveLogInMemoryToFileAsync(); op.Wait(); if (op.IsFaulted) { throw new Exception("After an app error occurred, there was a failure to save the log file.", op.Exception); } LogFileGeneratedCount++; // For the sample, update the UI to show a log file has been generated. if (StatusChanged != null) { StatusChanged.Invoke(this, new LoggingScenarioEventArgs(LoggingScenarioEventType.LogFileGenerated, op.Result)); } } } }); } finally { IsBusy = false; } }
private void OnStatusValueChaned(string value) { StatusChanged?.Invoke(this, new ParserEventArgs(value)); }
protected virtual void OnStatusChanged() { StatusChanged?.Invoke(this, EventArgs.Empty); }
protected virtual void OnStatusChanged(StatusChangedEventArgs e) { StatusChanged?.Invoke(this, e); }