C
C#5mo ago
santisq

✅ Synchronous wait and swallow exceptions

hey all, looking for some feedback, I have something that is working but it doesn't look very pretty. was wondering if you could tell me a better way to do it. essentially, I need to synchronously wait a task before disposing, so: https://github.com/santisq/PSParallelPipeline/blob/40-have-pstask-return-the-runspace-to-the-runspacepool/src/PSParallelPipeline/Worker.cs#L40-L44 depends on https://github.com/santisq/PSParallelPipeline/blob/40-have-pstask-return-the-runspace-to-the-runspacepool/src/PSParallelPipeline/RunspacePool.cs#L108-L110 and is used in the catchs of the cmdlet processing methods https://github.com/santisq/PSParallelPipeline/blob/40-have-pstask-return-the-runspace-to-the-runspacepool/src/PSParallelPipeline/Commands/InvokeParallelCommand.cs. All feedback is appreciated.
10 Replies
Angius
Angius5mo ago
Any reason in particular you can't just make things properly async?
santisq
santisqOP5mo ago
powershell 🙂
Angius
Angius5mo ago
Ah, RIP
santisq
santisqOP5mo ago
(its a powershell cmdlet)
Angius
Angius5mo ago
Well, in that case, the usual way of running async over sync is .GetAwaiter().GetResult()
santisq
santisqOP5mo ago
yep problem is, those awaits run on a CancellationTokenSource.Cancel() so basically I need to synchronously await for them knowing that task is expected to be faulted
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
santisq
santisqOP5mo ago
thanks! already solved it
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
MODiX
MODiX5mo ago
If you have no further questions, please use /close to mark the forum thread as answered
Want results from more Discord servers?
Add your server