public static bool NotifyKill(long NotifyID) { System.Threading.Mutex mu = new System.Threading.Mutex(false, NotifyInfo.MUTEXNAME); try { mu.WaitOne(); } catch (System.Threading.AbandonedMutexException) { } try { NotifyInfo ninfo = NotifyInfo.Load_unlocked(); int index = ninfo.FindNEntryByID(NotifyID); if (-1 == index) { return(false); } ninfo.Notify.RemoveAt(index); ninfo.Save_unlocked(); return(true); } finally { mu.ReleaseMutex(); IDisposable dmu = mu; dmu.Dispose(); } }
public static void ClearNotify() { System.Threading.Mutex mu = new System.Threading.Mutex(false, NotifyInfo.MUTEXNAME); try { mu.WaitOne(); } catch (System.Threading.AbandonedMutexException) { } try { NotifyInfo ninfo = NotifyInfo.Load_unlocked(); if (ninfo.Notify.Count < 1) { return; } ninfo.Notify = new List <NotifyInfo.NEntry>(0); ninfo.Save_unlocked(); } finally { mu.ReleaseMutex(); IDisposable dmu = mu; dmu.Dispose(); } }
static NotifyInfo.NEntry _AddNotify(long WaitOnJID, string JobInfo, string email, string UserAdded, string UserMessage) { NotifyInfo.NEntry ne = new NotifyInfo.NEntry(); ne.WaitOnJID = WaitOnJID; ne.WaitOnJobInfo = JobInfo; string HistoryRegex = null; if (JobInfo != null) { HistoryRegex = MySpace.DataMining.AELight.Surrogate.WildcardRegexSubstring(JobInfo); if (!JobInfo.StartsWith("*")) { HistoryRegex = @"\b" + HistoryRegex; } if (!JobInfo.EndsWith("*")) { HistoryRegex += @"\b"; } } ne.WaitOnHistoryRegex = HistoryRegex; ne.Email = email; ne.UserAdded = UserAdded; ne.UserMessage = UserMessage; System.Threading.Mutex mu = new System.Threading.Mutex(false, NotifyInfo.MUTEXNAME); try { mu.WaitOne(); } catch (System.Threading.AbandonedMutexException) { } try { NotifyInfo ninfo = NotifyInfo.Load_unlocked(); NotifyInfo.NEntry result = ninfo.AddNotify_unlocked(ne); ninfo.Save_unlocked(); return(result); } finally { mu.ReleaseMutex(); IDisposable dmu = mu; dmu.Dispose(); } }