Keyinator
❔ Using JsonConvert to send over interface
This is code for a gameserver which has multiple modes. Depending on the mode the player is in it functions will perform differently.
I have a Property
current_mode
which is used for all of that. Now depending on the underlying class that current_mode is, the functions will perform differently.
So now to put that information from the server to the client, I wanted to send it via the method above.8 replies
Threading Return to old thread
I have to rephrase myself. It does not have to return to the original background thread but it should not stay on the main thread because then all following code will be run on the main thread subsequently putting a lot of load on it.
My goal of this function / helper was to translate example code that would look like this:
Because in the first example when you need to go to the main thread more frequently you're going to nest more and more
Task.Run
s28 replies
Threading Return to old thread
Basically the !server!-side code isn't multi-threading friendly and thus you often need to go to the main thread to execute some code.
This helper is supposed to do the following:
If already on main thread, execute the code
If not:
- go to main thread
- execute the function
- return to original (background) thread
(in order to not put too much load on the main thread)
28 replies