} // proc StartJob public Task ExecuteJobAsync(ICronJobExecute job, CancellationToken cancellation) { using (currentJobs.EnterWriteLock()) { if (currentJobs.FindIndex(c => job == c.Job) >= 0) { throw new InvalidOperationException("Job is already running."); } using (currentJobs.EnterReadLock()) { foreach (var j in currentJobs) { if (!job.CanRunParallelTo(j.Job)) { throw new InvalidOperationException(String.Format("Job is blocked (job: {0})", j.Job.DisplayName)); } } } Log.Info("jobstart: {0}", job.DisplayName); var currentJob = new CurrentRunningJob(this, job, cancellation); currentJobs.Add(currentJob); return(currentJob.Task); } } // func ExecuteJobAsync
private XElement HttpDumpAction(bool mini = false) { // check for the procdump.exe var procDump = Config.Element(xnServer)?.GetAttribute("procdump", String.Empty); if (String.IsNullOrEmpty(procDump) || !File.Exists(procDump)) { throw new ArgumentException("procdump.exe is not available."); } // prepare arguments var sbArgs = new StringBuilder(); if (!mini) { sbArgs.Append("-ma "); // dump all } sbArgs.Append("-o "); // overwrite existing dump sbArgs.Append("-accepteula "); // accept eula sbArgs.Append(Process.GetCurrentProcess().Id).Append(' '); // process id // create the dump in the temp directory DumpFileInfo fi; using (dumpFiles.EnterWriteLock()) { var newId = ++lastDumpFileInfoId; dumpFiles.Add(fi = new DumpFileInfo(newId, Path.Combine(Path.GetTempPath(), $"DEServer_{newId:000}.dmp"))); } sbArgs.Append(fi.FileName); // prepare calling procdump ProcessStartInfo psi = new ProcessStartInfo(procDump, sbArgs.ToString()); psi.UseShellExecute = false; psi.RedirectStandardOutput = true; using (var p = Process.Start(psi)) { if (!p.WaitForExit(5 * 60 + 1000)) { p.Kill(); } var outputText = p.StandardOutput.ReadToEnd(); return(DEConfigItem.SetStatusAttributes( new XElement("return", new XAttribute("id", fi.Id), new XAttribute("exitcode", p.ExitCode) ), p.ExitCode > 0, outputText )); } } // proc HttpDumpAction
private void AddEventSession(EventSession eventSession) { using (eventSessions.EnterWriteLock()) eventSessions.Add(eventSession); } // proc AddEventSession