Closed slash-under closed 1 year ago
A better way could potentially be checking if we are already in that thread, if not, then queue it (if this is possible we should also take a look at all queuing code throughout the mod as well and apply the same fix).
That is definitely necessary, as we might call the Disconnect method from different threads. The QueueMainThread
method should already check if it is in the main thread and execute it directly if that is the case. It looks correct in the decompiled code, but it doesn't seem to work properly when looking at the reported stack trace. This might be a problem due to shutdown of the game.
We should investigate that problem further, but for this particular issue, I would propose a different fix. I think we should always execute the Disconnect
method in the simulation thread to prevent any race conditions on the different modules that are reset.
Then the QueueMainThread
should also work again (probably).
Fixes #291
This assumes that there is no case where the call will occur off the main thread -- if so, the existing call could be wrapped in a try/catch to isolate this fix.