Need to call function on main thread, while the worker thread is running.

I have data coming from serial ports at random intervals.
A work thread runs indefinitely until the serial port closes,
data is evaluated in while loop as long as the serial port is open,
once a string is recieved, a function is called in blueprint.

Ex: EventStringRecieved

That particular function is running on worker thread beacuse worker thread is active and the while loop is running.
It crashes if I’m accessing any gameplay objects. Accessing gameplay objects other than main threads crashes the game.

How to run the function EventStringRecieved on main thread ?

Im calling the work thread using AsyncTask
Ex code:


EventStringRecieved();// Calls function in blueprint // // No crashes, aslong as gameplay objects are not accessed//



void AMyActor::RunLoopActivity(APlayerPC* PControllerVar)
(new FAutoDeleteAsyncTask<LoopActivity>(PControllerVar))->StartBackgroundTask(); // creating the work thread using "FAutoDeleteAsyncTask "


please do help with this