From 271df45b703ad9e6f8c9c3728702bbc4cfe55add Mon Sep 17 00:00:00 2001 From: timyhac Date: Wed, 9 Oct 2024 07:05:55 +1100 Subject: [PATCH] We have to retrieve the Status because `plc_tag_create_ex` returns either an error (<0) or a handle according to the core library documentation. --- src/libplctag/Tag.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libplctag/Tag.cs b/src/libplctag/Tag.cs index 9f2f8ff..607d701 100644 --- a/src/libplctag/Tag.cs +++ b/src/libplctag/Tag.cs @@ -718,12 +718,12 @@ public async Task InitializeAsync(CancellationToken token = default) } // Await while Pending - if(result == (int)Status.Pending) + if(GetStatus() == Status.Pending) { await createTask.Task.ConfigureAwait(false); } - // Tear down and throw on error + // On error, tear down and throw if(createTask.Task.Result != Status.Ok) { RemoveEventsAndRemoveCallback();