2 years ago

#58262

test-img

asuracode

some of my code is being skipped over , why?

is there a reason why VS studio 2022 debugger is skipping lines of code?

i have tried

  • Breakpoints but they still get skipped over

  • I already un-ticked "just my code" in the debug settings

    public TextLogger(){ _ = Task.Run(() => LogAsync(filePath, _LogQue, tokenSource.Token));}

          private static async Task LogAsync(string FilePath, BufferBlock<LogInformations> que,CancellationToken token)
             {
                 Console.WriteLine("In LogAsync ");
                 using var sw = new StreamWriter(File.Open(FilePath,FileMode.Append, FileAccess.Write, FileShare.Read));
                 Console.WriteLine("Still in logAsync ");
                 while (true)
                 {
                     try
                     { 
                         var logItem = await que.ReceiveAsync(token).ConfigureAwait(false);
                         string formattedMessage = CreateMessage(logItem, true);
                         Console.WriteLine("after create message.");
                         await sw.WriteAsync(formattedMessage).ConfigureAwait(false);
    
                     }
                     catch (OperationCanceledException)
                     {
                         Console.WriteLine("Cancelled");
                     }
                 }
    
    
             }
    

where the console output is:

In LogAsync

i used a breakpoint and it steps into:

 using var sw = new StreamWriter(File.Open(FilePath,FileMode.Append, FileAccess.Write, FileShare.Read));

then seems to exit the method for some reason.

c#

visual-studio

.net-core

visual-studio-debugging

0 Answers

Your Answer

Accepted video resources