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 14
14
//
15
15
#endregion
16
16
17
+ using Serilog ;
17
18
using System ;
18
19
using System . Threading ;
19
- using Serilog ;
20
20
21
21
namespace ConsoleDemo
22
22
{
@@ -33,15 +33,23 @@ private static void Main(string[] args)
33
33
34
34
try
35
35
{
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();
38
38
39
39
Console . WriteLine ( "Writing messages to the most recent Notepad you opened..." ) ;
40
40
41
41
Log . Debug ( "Getting started" ) ;
42
42
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
+ }
45
53
46
54
Log . Warning ( "No coins remain at position {@Position}" , new { Lat = 25 , Long = 134 } ) ;
47
55
Original file line number Diff line number Diff line change @@ -57,7 +57,10 @@ public override void Flush()
57
57
// No instances of Notepad found... Nothing to do
58
58
return ;
59
59
}
60
+ }
60
61
62
+ if ( _currentNotepadEditorHandle == IntPtr . Zero )
63
+ {
61
64
var notepadWindowHandle = currentNotepadProcess . MainWindowHandle ;
62
65
63
66
var notepadEditorHandle = FindNotepadEditorHandle ( notepadWindowHandle ) ;
You can’t perform that action at this time.
0 commit comments