From 98298339c55a40fecdc17dd37331af1497bb1da8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erkan=20=C3=87olak?= Date: Wed, 24 Jan 2024 23:40:02 +0100 Subject: [PATCH] Fixed 'added dispose' since.... the Finish method is not marked as static, and it will be called within a static context and using the Wait method to synchronously wait for the completion of the asynchronous device/conn Disconnect. --- Program.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Program.cs b/Program.cs index fe7d93e..c6fad62 100644 --- a/Program.cs +++ b/Program.cs @@ -196,12 +196,12 @@ static async Task Main(string[] args) return code; } - private void Finish() + private static void Finish() { - if(device != null) - await device.Disconnect(); - if(conn != null) - await conn.Disconnect(); + if (device != null) + device.Disconnect().Wait(); // Use .Wait() to synchronously wait for completion. Deadlocks uncritical here, because the program is exiting anyway. + if (conn != null) + conn.Disconnect().Wait(); }