Calling a function in my GameInstance from a thread crashes

Hello friends,

In my Game Instance class I create a thread class, and pass my self into it. I run the thread, and in the while loop, it will tell the game instance class (“Hey”).

	while (StopTaskCounter.GetValue() == 0)

		static float lol;
		lol += 1.0f;
		FString TheFloatStr = FString::SanitizeFloat(lol);
		if (customGameInstance)
		//prevent thread from using too many resources

The problem is when I debug to the screen,

	//GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("This is an on screen message!"));

from “ClientMessage(TheFloatStr);” method, it crashes.

So it looks you can’t do a lot from threads, but calculate stuff. My game instance needs this because it needs to receive updates from the server.

From developing in Java, I’m aware the that child thread should not touch the parent threads children, same goes for UE4 as Rama said, don’t destroy/modify GameObjects in custom threads.

P.S I got the code from Rama - great guy!