File tree Expand file tree Collapse file tree 2 files changed +16
-5
lines changed
src/Serilog.Sinks.Notepad/Sinks/Notepad/Interop Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change 1414//
1515#endregion
1616
17+ using Serilog ;
1718using System ;
1819using System . Threading ;
19- using Serilog ;
2020
2121namespace ConsoleDemo
2222{
@@ -33,15 +33,23 @@ private static void Main(string[] args)
3333
3434 try
3535 {
36- Console . WriteLine ( "Open a `notepad.exe` instance and press <enter> to continue..." ) ;
37- Console . ReadLine ( ) ;
36+ // Console.WriteLine("Open a `notepad.exe` instance and press <enter> to continue...");
37+ // Console.ReadLine();
3838
3939 Console . WriteLine ( "Writing messages to the most recent Notepad you opened..." ) ;
4040
4141 Log . Debug ( "Getting started" ) ;
4242
43- Log . Information ( "Hello {Name} from thread {ThreadId}" , Environment . GetEnvironmentVariable ( "USERNAME" ) ,
44- Thread . CurrentThread . ManagedThreadId ) ;
43+ var startTime = DateTime . Now ;
44+
45+ while ( DateTime . Now - startTime < TimeSpan . FromMinutes ( 1 ) )
46+ {
47+
48+ Log . Information ( "Hello {Name} from thread {ThreadId}" , Environment . GetEnvironmentVariable ( "USERNAME" ) ,
49+ Thread . CurrentThread . ManagedThreadId ) ;
50+
51+ Thread . Sleep ( 1000 ) ;
52+ }
4553
4654 Log . Warning ( "No coins remain at position {@Position}" , new { Lat = 25 , Long = 134 } ) ;
4755
Original file line number Diff line number Diff line change @@ -57,7 +57,10 @@ public override void Flush()
5757 // No instances of Notepad found... Nothing to do
5858 return ;
5959 }
60+ }
6061
62+ if ( _currentNotepadEditorHandle == IntPtr . Zero )
63+ {
6164 var notepadWindowHandle = currentNotepadProcess . MainWindowHandle ;
6265
6366 var notepadEditorHandle = FindNotepadEditorHandle ( notepadWindowHandle ) ;
You can’t perform that action at this time.
0 commit comments