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