C
C#6mo 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
Angius6mo ago
Any reason in particular you can't just make things properly async?
santisq
santisqOP6mo ago
powershell 🙂
Angius
Angius6mo ago
Ah, RIP
santisq
santisqOP6mo ago
(its a powershell cmdlet)
Angius
Angius6mo ago
Well, in that case, the usual way of running async over sync is .GetAwaiter().GetResult()
santisq
santisqOP6mo 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 User6mo ago
Message Not Public
Sign In & Join Server To View
santisq
santisqOP6mo ago
thanks! already solved it
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
MODiX
MODiX6mo 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