public static void HandleException(Exception ex, string handlerPolicy = "unused" )
        {

            SimpleLogging.LogMessage("Exception type=" + ex.GetType().FullName);
            SimpleLogging.LogMessage("Excption stacktrace: " +ex.StackTrace + "\r\nEx Message:" + ex.Message );
            
        }
        public static void AddJob(BackgroundWorker worker, HttpSessionState Session)
        {
            if (!Instance().IsBusy)
            {
                SimpleLogging.LogMessage("Warning! ShortTermJobQue = Adding Job to stopped Job Queue");
            }

            Instance().jobQueue.Enqueue(new SessionJob()
            {
                SessionId = Session.SessionID,
                Worker    = worker
            });
        }
Esempio n. 3
0
        public static void CompileScript(string scriptPath, ref IDisposable compiled)
        {
            SimpleLogging.LogMessage("scriptserver compiling linkpad script: " + scriptPath);
            try
            {
                var dbCtx = LINQPad.Util.Compile(scriptPath, false);

                compiled = dbCtx;
            }
            catch (Exception e)
            {
                SimpleExceptionHandling.HandleException(e);
            }
        }
Esempio n. 4
0
        public static object ReRunScript(object[] args, ScriptCacheItem script)
        {
            var result = (script.CompiledScript as LINQPad.ObjectModel.QueryCompilation).Run(LINQPad.QueryResultFormat.Text, args);

            if (result.Exception != null)
            {
                SimpleLogging.LogMessage(script.ScriptFile + " run returned with exception.");
                SimpleExceptionHandling.HandleException(result.Exception);
                return(result.Exception);
            }
            else
            {
                return(result.ReturnValue);
            }
        }
 public static ShortTermJobQueue Instance()
 {
     if (instance == null)
     {
         instance = new ShortTermJobQueue();
     }
     else
     {
         if (!instance.IsBusy)
         {
             SimpleLogging.LogMessage("Warning!  Call to ShortTermJobQueue.Instance() returning a stopped background worker");
         }
     }
     return(instance);
 }
 void ShortTermJobQueue_DoWork(object sender, DoWorkEventArgs e)
 {
     SimpleLogging.LogMessage("ShortTermJobQueue starting......");
     try
     {
         while (!this.CancellationPending)
         {
             StartJobs();
             System.Threading.Thread.Sleep(500);  // Runs every 1/2.
         }
     }
     catch (Exception stjqe)
     {
         SimpleExceptionHandling.HandleException(stjqe, "Background");
         throw stjqe;
     }
 }
        void StartJobs()
        {
            if (jobQueue != null)
            {
                while (jobQueue.Count() > 0 && !this.CancellationPending)
                {
                    SessionJob job = null;
                    jobQueue.TryDequeue(out job);

                    if (job != null)
                    {
                        SimpleLogging.LogMessage("ShortTermJobQueue starting a:" + job.Worker.GetType().FullName);

                        job.Worker.RunWorkerAsync();
                    }
                }
            }
        }
        void ScriptDisposeBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            // Going to wait 4 second to let all other threads finish running the script.
            System.Threading.Thread.Sleep(4000);


            if (ConfigurationManager.AppSettings["debug"] != null && ConfigurationManager.AppSettings["debug"] == "true")
            {
                SimpleLogging.LogMessage("ScriptDisposeBackgroundWorker disposing: " + CachedScript.ScriptFile + " requesting thread=" + this.RequestingThreadId.ToString());
            }

            try
            {
                CachedScript.CompiledScript.Dispose();

                CachedScript.CompiledScript = null;
            }
            catch (System.Threading.AbandonedMutexException ex)
            {
                // Oh well.....  Just eat it.
                SimpleLogging.LogMessage("Exception displosing script.");
                SimpleExceptionHandling.HandleException(ex);
            }
        }
 void ShortTermJobQueue_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     SimpleLogging.LogMessage("Notice!  ShortTermJobQueue_RunWorkerCompleted");
 }
 public static void Shutdown()
 {
     Instance().CancelAsync();
     SimpleLogging.LogMessage("ShortTermJobQueue shutting down..");
     instance = null;
 }