✅ 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
catch
s 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
Any reason in particular you can't just make things properly async?
powershell 🙂
Ah, RIP
(its a powershell cmdlet)
Well, in that case, the usual way of running async over sync is
.GetAwaiter().GetResult()
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 faultedUnknown User•6mo ago
Message Not Public
Sign In & Join Server To View
thanks! already solved it
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
If you have no further questions, please use /close to mark the forum thread as answered