static void WriteToDb() { using (var db = new ArgonDB()) try { db.BeginTransaction(); lock (ProcessDataList) foreach (ProcessData p in ProcessDataList) { if (p.ProcessorLoadPercent != 0) { db.InsertAsync(new ProcessCounter { Time = p.Time, Name = p.Name, Path = p.Path, ProcessorLoadPercent = p.ProcessorLoadPercent }); } } lock (NetworkTrafficList) { foreach (NetworkTraffic n in NetworkTrafficList) { db.InsertAsync(n); } NetworkTrafficList.Clear(); } db.CommitTransaction(); } catch { db.RollbackTransaction(); } }
public static void ShowNotification(int PID, string applicationName, string applicationPath, CustomNotification.ActionType actionType) { DateTime time = DateTime.Now; Application.Current.Dispatcher.BeginInvoke( new Action(() => _notifier.ShowNotification(PID, applicationName, applicationPath, actionType, time))); AddToNotificationList(applicationName, applicationPath, actionType, time); Task.Run(() => { using (var db = new ArgonDB()) db.InsertAsync(new Notification { Time = time.Ticks, ApplicationName = applicationName, ApplicationPath = applicationPath, Type = (int)actionType, NotActivated = 1 }); }); try { Application.Current.Dispatcher.BeginInvoke( new Action(() => { ((MainWindow)Application.Current.MainWindow).Notifications.UpdateViewSource(); })); } catch { } }
public static void AddToWhitelist(int PID, string name, string path) { var app = new WhitelistedApp { Name = name, Path = path }; using (var db = new ArgonDB()) try { db.InsertAsync(app); } catch { } CpuSuspendWhitelist.Add(app); SuspendedProcessList.RemoveAll(x => x.ID == PID); }