private void Window_Closed(object sender, EventArgs e)
        {
            // Cleanup TraceSession, Listener and temp update files...

            TraceEventSession.GetActiveSession(SessionName)?.Stop(true);
            _backgroundWorker.Dispose();

            Trace.Close();
            Trace.Listeners.Remove("listenerSyncMLStream");

            if (_updateStarted)
            {
                return;
            }
            try
            {
                if (_updateTempFileName == null)
                {
                    return;
                }
                if (!File.Exists(_updateTempFileName))
                {
                    File.Delete(_updateTempFileName);
                }
            }
            catch (Exception)
            {
                // ignored
            }
        }
        public static void Main(string[] args)
        {
            CreaTrazaEnArchivo("log");
            var v = new VectorFlexible <Chorras>();

            for (int i = 0; i < 10; i++)
            {
                v.Add(new Chorras {
                    X = i + 1
                });
            }

            //v.Add(null);

            //for (int i = 0; i < v.Count; i++)
            //{
            //	Console.WriteLine(i + ": " + v[i]);
            //}

            while (!v.EsVacia())
            {
                v.Pop();
            }

            Trace.Close();
            return;
        }
示例#3
0
        protected virtual void          Dispose(bool aDisposing)
        {
            if (!mDisposed)
            {
                if (aDisposing)
                {
                    Trace.Close();

                    if (mFileTraceListener != null)
                    {
                        mFileTraceListener.Dispose();
                        mFileTraceListener = null;
                    }

                    if (mLogTraceListener != null)
                    {
                        mLogTraceListener.Dispose();
                        mLogTraceListener = null;
                    }

                    disposeLogForm();
                }
                mDisposed = true;
            }
        }
示例#4
0
        public void Test()
        {
            Trace.Listeners.Clear();
            string timeStamp           = DateTime.Now.ToString("yyyy_MMdd_hhmmss_");
            TextWriterTraceListener tl = new TextWriterTraceListener($".\\Logs\\{timeStamp}Log.log");

            tl.TraceOutputOptions = TraceOptions.DateTime | TraceOptions.Callstack | TraceOptions.ProcessId;
            Trace.Listeners.Add(tl);

            Trace.WriteLine("Testing Starts");
            Random rand = new Random();

            Trace.Write("正在进行某种复杂运算");
            for (int i = 0; i < 30; i++)
            {
                int SleepMS = rand.Next(10, 50);
                Thread.Sleep(SleepMS);
                Trace.Write(".");
            }
            Trace.WriteLine("完成!");
            Trace.TraceWarning("某种警告!");



            Trace.WriteLine("Testing Ends");
            Trace.Close();
        }
示例#5
0
 private static async Task RunTaskAsync()
 {
     Trace.WriteLine("Start task", "ADBlocker");
     Trace.WriteLine($"Start Time: {DateTime.UtcNow.ToString("dd/MM/yyyy HH:mm:ss.fff")}", "ADBlocker");
     try
     {
         InitializeHttpClient();
         await RunBlockingTaskAsync();
         await RunScheduledTaskAsync();
         await UpdateTaskRuntimeAsync();
     }
     catch (Exception ex)
     {
         ProcessException(ex);
     }
     finally
     {
         Trace.WriteLine($"End Time: {DateTime.UtcNow.ToString("dd/MM/yyyy HH:mm:ss.fff")}", "ADBlocker");
         Trace.WriteLine("End Task", "ADBlocker");
         Trace.WriteLine("");
         Trace.Close();
         _client?.Dispose();
         _handler?.Dispose();
     }
 }
示例#6
0
        private static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += (sender, e) => Trace.WriteLine(e.ExceptionObject);

            Trace.WriteLine("Starting with arguments: " + args.ToString(", "));

            RadoslavTaskProcessor processor;

            try
            {
                processor = RadoslavServiceLocator.DefaultInstance.ResolveSingle <RadoslavTaskProcessor>();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex);

                Trace.Close();

                return;
            }

            Console.Title = "Task Processor {0}".FormatInvariant(processor.Id);

            Helpers.WaitForEvent(
                handler => processor.Stopped += handler,
                processor.Start);

            if (processor != null)
            {
                processor.Dispose();
            }

            Trace.Close();
        }
示例#7
0
 /// <summary>
 /// Closes all existing Trace Log.
 /// </summary>
 public static void DisposeTraceLog()
 {
     if (Trace.Listeners.Count == 0)
     {
         Trace.Close();
     }
 }
示例#8
0
        public static async Task NoContextTest()
        {
            const string TraceFileName = "Transactions.TransactionHandlerTest.NoContextTest.log.csv";

            try
            {
                Trace.AutoFlush = true;
                Trace.Listeners.Add(new TextWriterTraceListener(new StreamWriter(TraceFileName, false)));

                using (var dataSource = new MockDataSource("ds", "tx"))
                {
                    try
                    {
                        TransactionContext.Created += NoContextTest_TransactionContextCreated;

                        var command = new MockDataCommand();
                        await dataSource.ExecuteNonQuery(command).ConfigureAwait(false);
                    }
                    finally
                    {
                        TransactionContext.Created -= NoContextTest_TransactionContextCreated;
                    }
                }

                Assert.IsNull(TransactionContext.CurrentTransactionContext);
            }
            finally
            {
                Trace.Close();
            }

            CheckTraceLog(TraceFileName);
        }
示例#9
0
 internal static void Truncate()
 {
     Trace.Flush();
     Trace.Close();
     Trace.Listeners.Clear();
     try
     {
         var logFile = Path.GetFileNameWithoutExtension(Application.ExecutablePath) + ".log";
         var fi      = new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, logFile));
         if (fi.Exists)
         {
             var trimSize = Settings.Default.logFileSizeMB * 1024 * 1024;
             if (fi.Length > trimSize)
             {
                 using (var ms = new MemoryStream(trimSize))
                     using (var s = new FileStream(logFile, FileMode.Open, FileAccess.ReadWrite))
                     {
                         s.Seek(-trimSize, SeekOrigin.End);
                         var bytes = new byte[trimSize];
                         s.Read(bytes, 0, trimSize);
                         ms.Write(bytes, 0, trimSize);
                         ms.Position = 0;
                         s.SetLength(trimSize);
                         s.Position = 0;
                         ms.CopyTo(s);
                     }
             }
         }
     }
     catch
     {
     }
     Init();
 }
示例#10
0
        public static async Task SimpleTest()
        {
            const string TraceFileName = "Transactions.TransactionHandlerTest.SimpleTest.log.csv";

            try
            {
                Trace.AutoFlush = true;
                Trace.Listeners.Add(new TextWriterTraceListener(new StreamWriter(TraceFileName, false)));

                using (var dataSource = new MockDataSource("ds", "tx"))
                    using (var context = new TransactionContext(TransactionContextAffinity.RequiresNew))
                    {
                        var command = new MockDataCommand();
                        await dataSource.ExecuteNonQuery(command).ConfigureAwait(false);

                        context.VoteCommit();
                    }
            }
            finally
            {
                Trace.Close();
            }

            CheckTraceLog(TraceFileName);
        }
示例#11
0
        public static async Task NestedContextTest(TransactionContextTestNode testNode)
        {
            const int    IterationCount = 50;
            const string TraceFileName  = "Transactions.TransactionHandlerTest.NestedContextTest.log.csv";

            try
            {
                Trace.AutoFlush     = true;
                Trace.UseGlobalLock = true;
                Trace.Listeners.Add(new TextWriterTraceListener(new StreamWriter(TraceFileName, false)));

                Trace.WriteLine(testNode.ToString(), "NLight.Tests.Unit.Transactions.TransactionHandlerTest");

                var tasks = new List <Task>();
                for (int i = 0; i < IterationCount; i++)
                {
                    tasks.Add(Task.Factory.StartNew(() => ExecuteNode(testNode), TaskCreationOptions.DenyChildAttach).Unwrap());
                }

                await Task.WhenAll(tasks).ConfigureAwait(false);
            }
            finally
            {
                Trace.Close();
            }

            CheckTraceLog(TraceFileName);
        }
示例#12
0
        static void Main(string[] args)
        {
            var consoleTraceListener = new TextWriterTraceListener(Console.Out);

            Trace.Listeners.Add(consoleTraceListener);

            try
            {
                ArgumentsValidation(args);

                using (var connection = new Connection(Address.ToString(), Port))
                {
                    Controller controller = new Controller(connection);

                    //await controller.Process().ConfigureAwait(false); //This requires C# 7.1 or later, TeamCity build and packaging is not using this yet.
                    controller.Process().Wait();
                }
            }
            catch (System.Exception ex)
            {
                Trace.WriteLine(ex.Message);
                Trace.WriteLine($"Exception Details: \n {ex.StackTrace}");
            }
            finally
            {
                Trace.Flush();
                Trace.Listeners.Remove(consoleTraceListener);
                consoleTraceListener.Close();
                Trace.Close();
            }
        }
示例#13
0
        static void Main(string[] args)
        {
            ConsoleTraceListener listener = new ConsoleTraceListener();

            Trace.Listeners.Add(listener);

            string ProjPath = Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.Parent.Parent.FullName;
            string DirPath  = ProjPath + @"\pics_to_recognize\";

            OnnxClassifier clf = new OnnxClassifier(ProjPath + @"\model\resnet50-v2-7.onnx");

            PredictionQueue cq = new PredictionQueue();

            cq.Enqueued += PredictionCaught;
            Task keyBoardTask = Task.Run(() =>
            {
                Trace.WriteLine("*** Press Esc to cancel");
                while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape))
                {
                }
                clf.StopPrediction();
            });

            clf.PredictAll(cq, new DirectoryInfo(DirPath).GetFiles());

            Trace.Listeners.Remove(listener);
            Trace.Close();
        }
示例#14
0
 static void Main()
 {
     Trace.TraceInformation("Program Information");
     Trace.TraceWarning("Program Warning");
     Trace.TraceError("Program error");
     Trace.Close();
 }
示例#15
0
 public void Teardown()
 {
     TransportIntegration = null;
     Trace.Flush();
     Trace.Close();
     Trace.Listeners.Remove(textWriterTraceListener);
 }
示例#16
0
 /// <summary>
 /// FinalizeTrace method implmentation
 /// </summary>
 protected virtual void FinalizeTrace(TraceListener listen)
 {
     Trace.Flush();
     Trace.Close();
     listen.Close();
     Trace.Listeners.Remove("MFATrace");
 }
示例#17
0
 public void escribirArchivo(eventosLogs eventos)
 {
     try
     {
         string Directorio = ConfigurationManager.AppSettings["Dir"];
         Trace.Listeners.Add(new TextWriterTraceListener(Directorio + @"\" + eventos.Archivo));
         Trace.AutoFlush = true;
         Trace.Indent();
         string cadena = Environment.NewLine + DateTime.Now.ToLocalTime().ToString();
         Trace.WriteLine(cadena + eventos.Mensaje);
         Trace.Unindent();
         Trace.Close();
         foreach (string item in Directory.GetFiles(Path.GetFileName(eventos.Archivo)))
         {
             if (item != eventos.Archivo)
             {
                 File.Delete(item);
             }
         }
     }
     catch (Exception ex)
     {
         ex.Message.ToString();
     }
 }
示例#18
0
文件: Log.cs 项目: voltura/WeekNumber
 /// <summary>
 ///     Truncate log
 /// </summary>
 internal static void Truncate()
 {
     try
     {
         Trace.Flush();
         Trace.Close();
         Trace.Listeners.Clear();
         FileInfo fi = new FileInfo(logFileFullPath);
         if (fi.Exists)
         {
             int trimSize = Settings.GetIntSetting(Resources.MaxLogFileSizeInMB, DEFAULT_LOGFILE_SIZE_IN_MEGABYTES) * 1024 * 1024;
             if (fi.Length > trimSize)
             {
                 using (MemoryStream ms = new MemoryStream(trimSize))
                     using (FileStream s = new FileStream(logFileFullPath, FileMode.Open, FileAccess.ReadWrite))
                     {
                         s.Seek(-trimSize, SeekOrigin.End);
                         byte[] bytes = new byte[trimSize];
                         s.Read(bytes, 0, trimSize);
                         ms.Write(bytes, 0, trimSize);
                         ms.Position = 0;
                         s.SetLength(trimSize);
                         s.Position = 0;
                         ms.CopyTo(s);
                     }
             }
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex);
     }
     Init();
 }
 private void Quit(object sender, EventArgs e)
 {
     Trace.WriteLineIf(Tsw.TraceVerbose, DateTime.Now.ToString() +
                       "  Program Closed");
     Trace.Close();
     this.Close();
 }
示例#20
0
        static async Task Main(string[] args)
        {
            ConsoleTraceListener consoleTraceListener = new ConsoleTraceListener();

            consoleTraceListener.Name = "Main output";
            Trace.Listeners.Add(consoleTraceListener);

            try
            {
                //TODO... arg error checking required.

                Trace.WriteLine($"Starting NutKitDotNet on {args[0]}:{args[1]}");
                var address = args[0];
                var port    = Convert.ToInt32(args[1]);

                using var connection = new Connection(address, port);
                Controller controller = new Controller(connection);
                await controller.Process().ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
                Trace.WriteLine($"Exception Details: \n {ex.StackTrace}");
            }
            finally
            {
                Trace.Flush();
                Trace.Listeners.Remove(consoleTraceListener);
                consoleTraceListener.Close();
                Trace.Close();
            }
        }
示例#21
0
        // Dispose(bool disposing) executes in two distinct scenarios.
        // If disposing equals true, the method has been called directly
        // or indirectly by a user's code. Managed and unmanaged resources
        // can be disposed.
        // If disposing equals false, the method has been called by the
        // runtime from inside the finalizer and you should not reference
        // other objects. Only unmanaged resources can be disposed.
        private void Dispose(bool disposing)
        {
            // Check to see if Dispose has already been called.
            if (!disposed)
            {
                // If disposing equals true, dispose all managed
                // and unmanaged resources.
                if (disposing)
                {
                    // Dispose managed resources.
                    ////component.Dispose();
                    outputImageBuffer.Dispose();
                    Trace.Flush();
                    Trace.Close();
                    SimPLC  = null;
                    Project = null;
                }

                // Call the appropriate methods to clean up
                // unmanaged resources here.
                // If disposing is false,
                // only the following code is executed.
                ////CloseHandle(handle);
                ////handle = IntPtr.Zero;
            }
            disposed = true;
        }
示例#22
0
文件: Log.cs 项目: voltura/WeekNumber
 /// <summary>
 ///     Init log
 /// </summary>
 internal static void Init()
 {
     try
     {
         if (!Directory.Exists(appDataFolder))
         {
             Directory.CreateDirectory(appDataFolder);
         }
         Trace.Listeners.Clear();
         if (!Settings.SettingIsValue(Resources.UseApplicationLog, "True"))
         {
             Trace.Listeners.Clear();
             Trace.Flush();
             Trace.Close();
             if (File.Exists(logFileFullPath))
             {
                 File.Delete(logFileFullPath);
             }
             return;
         }
         FileStream fs = new FileStream(logFileFullPath, FileMode.Append, FileAccess.Write, FileShare.ReadWrite | FileShare.Delete, 1024, FileOptions.WriteThrough);
         TextWriterTraceListener traceListener = new TextWriterTraceListener(fs);
         Trace.Listeners.Add(traceListener);
         Trace.AutoFlush     = true;
         Trace.UseGlobalLock = false;
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex);
     }
 }
示例#23
0
 /// <summary>
 /// Finalize and close the output log.
 /// </summary>
 public static void LogFinalize()
 {
     Trace.Flush();
     TxtListener.Close();
     Trace.Close();
     Trace.Listeners.Remove(TxtListener);
 }
示例#24
0
 public static void Assert(bool b, DbgKey key)
 {
     Trace.WriteLine("Assert: " + key.Name);
     if (problems.Contains(key))
     {
         string explanation = GetExplanation(key);
         MessageBox.Show(
             explanation,
             "Program Stopped",
             MessageBoxButtons.OK,
             MessageBoxIcon.Stop,
             MessageBoxDefaultButton.Button1);
     }
     else
     {
         MessageBox.Show(
             "A fatal problem has occurred.\n\nReference: " + key.Name,
             "Program Stopped",
             MessageBoxButtons.OK,
             MessageBoxIcon.Stop,
             MessageBoxDefaultButton.Button1);
     }
     Trace.Close();
     Process.GetCurrentProcess().Kill();
 }
示例#25
0
 private void Dispose(bool disposing)
 {
     if (disposing)
     {
         Trace.Close();
         GC.SuppressFinalize(this);
     }
 }
示例#26
0
 static void AppExit(object sender, EventArgs e)
 {
     ((IDisposable)ServiceHost.INSTANCE).Dispose();
     if (tracelog != null)
     {
         Trace.Close();
     }
 }
示例#27
0
        public void CloseTest()
        {
            var listener = new TestTraceListener();

            Trace.Listeners.Add(listener);
            Trace.Close();
            Assert.Equal(1, listener.GetCallCount(Method.Dispose));
        }
示例#28
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            // add a listener
            EventLogTraceListener logListener =
                new EventLogTraceListener("Application");

            Trace.Listeners.Add(logListener);
            TraceSwitch traceSwitch = new TraceSwitch("General", ("Font Replacer Supervisor"));

            traceSwitch.Level = TraceLevel.Verbose;

            // access the current document
            Document doc = commandData.Application.ActiveUIDocument.Document;

            try
            {
                // generate and show a selection dialog box
                SelectFontWindow fontWindow = new SelectFontWindow();
                fontWindow.ShowDialog();

                // get the selected font
                Font newFont = fontWindow.PickedFont;
                if (newFont == null) // if no font has been picked, an empty string is returned.
                {
                    return(Result.Cancelled);
                }

                if (fontWindow.TextNoteTypes)
                {
                    FontReplacer.ReplaceFontInTextNotes(doc, newFont);
                }
                if (fontWindow.DimensionTypes)
                {
                    FontReplacer.ReplaceFontInDimTypes(doc, newFont);
                }
                if (fontWindow.Families)
                {
                    FontReplacer.ReplaceFontInFamilies(doc, newFont);
                }

                return(Result.Succeeded);
            }
            catch (Exception ex)
            {
                Trace.WriteIf(traceSwitch.TraceError,
                              string.Format("Message:{0}\nStackTrack:{1}",
                                            ex.Message, ex.StackTrace));
                TaskDialog.Show("Exception", ex.Message);
                return(Result.Failed);
            }
            finally
            {
                Trace.WriteIf(traceSwitch.TraceVerbose,
                              FontReplacer.ProcessedFamilies);
                Trace.Flush();
                Trace.Close();
            }
        }
示例#29
0
        static void Main(string[] args)
        {
            /*
             * using (var reader = new StreamReader( @"s:\source\repos\Robotron_2084\VirtuRoX\tmp\MemoryOperations.csv" ))
             * using (var csv = new CsvReader( reader, Thread.CurrentThread.CurrentCulture )) {
             *  _records = csv.GetRecords<RecordedMemoryOperation>().ToList();
             * }
             *
             * var bla = _records.GroupBy( info => info.Address ).Select( group => new Tuple<int, int>( group.Key, group.Count() ) ).OrderBy( x => x.Item1 );
             * _dict = bla.ToDictionary( x => x.Item1 );
             * Console.WriteLine( _dict.Count );
             * object[,] res = GetReadCounts( 224, 32 );
             * Console.WriteLine( _dict.ToString() );
             * return;
             */
            /*
             * AsmLinesWindow wnd1 = new AsmLinesWindow();
             * wnd1.ShowDialog();
             * return;
             */

            Parser.Default.ParseArguments <Options>(args)
            .WithParsed <Options>(o => {
                ConsoleTraceListener tracer = new ConsoleTraceListener();
                Trace.Listeners.Add(tracer);
                Trace.WriteLine("Main() start");

                AsmReader reader = new AsmReader(@"s:\source\repos\Robotron_2084\Disassemblies\Robotron (Apple).asm");
                //reader.Test1();

                Trace.WriteLine($"Running workbench{(o.Breakpoints ? "with" : "without")} breakpoints: -b {o.Breakpoints}");

                using (_machineOperator = new MachineOperator()) {
                    if (o.Breakpoints)
                    {
                        // _machineOperator.OnPaused += MachineOperator_OnPaused;
                        _workbench = new Workbench(_machineOperator, o);
                    }
                    else
                    {
                        _machineOperator.OnLoaded += ( MachineOperator mo ) => mo.LoadStateFromFile(mo.BlaBin);
                    }

                    //Form1 frm = new Form1();
                    //frm.Populate();
                    //frm.Show();

                    _machineOperator.ShowDialog();
                }


                Trace.WriteLine("Main() end");
                Trace.Flush();
                Trace.Listeners.Remove(tracer);
                tracer.Close();
                Trace.Close();
            });
        }
示例#30
0
 static void Domain_ProcessExit(object sender, EventArgs e)
 {
     // Kill all spawned processes (Console instead of Log because logging is closed at this time anyway)
     if (ShouldKillProcesses && !Utils.IsRunningOnMono)
     {
         ProcessManager.KillAll();
     }
     Trace.Close();
 }