Download

FRunnableThread becomes blocking!

I’ve made my custom FRunnable following by this tutorial: A new, community-hosted Unreal Engine Wiki - Announcements and Releases - Unreal Engine Forums
But when I’m running my FRunnable, it blocks the main thread! Engine version 4.8. Code:



//.h
class Client :
	public FRunnable
{
public:
	Client();
	~Client();
	virtual bool Init() override
	{
		return true;
	};
	virtual uint32 Run() override;
	virtual void Stop() override{
		running = false;
	};
	virtual void Exit() override
	{
		Stop();
		trd->WaitForCompletion();
	};

	bool running = false;
private:
	FRunnableThread* trd;
};





//.cpp

Client::Client()
{
	UE_LOG(LogTemp, Warning, TEXT("Init..."));
        this->running = true;
	this->trd = FRunnableThread::Create(this, TEXT("Network Client"));
}


Client::~Client()
{
	if (this->trd != NULL)
	{
		trd->Kill(true);
		delete trd;
		trd = NULL;
	}
}

uint32 Client::Run(){
	FPlatformProcess::Sleep(0.03);
	while (running)
	{
		FPlatformProcess::Sleep(0.01);
		UE_LOG(LogTemp, Warning, TEXT("Running thread..."));

		//Do stuff
	}
	UE_LOG(LogTemp, Warning, TEXT("End of thread!"));

	return 0;
}



Calling it from overrided BeginPlay() in actor.

Hi, sorry to resurrect an old topic… but did you solve this? I am having the same issue…

Thanks!