Parse text file on seperate thread

Hey everyone,

I have just dipped into C++ (I’ve mainly worked in blueprints until this point) and I’m trying to set up multithreading. I followed the guide here:

and everything is working fine.

My only problem is, I want to have it parse a text file rather than calculate prime numbers. Would anyone be able to help me?

I’m parsing the text file using the FILE IO LOAD STRING FROM FILE node from Rama’s VictoryBPPlugin
Then I’m running a For Each Loop on the parsed array and adding the element to another array. (This is all handled in BP)
The text file has over 2 million strings in it so it’s causing my GUI to hang for way too long.
I just want this process to be handled on a separate thread so my GUI can function properly.

I thought of another way to explain this if it helps:

I have a blueprint function “SetDictionary” that I want to run on a separate thread.

My C++ code runs a function called “Calculate Prime Numbers”
I THINK this is the code that defines what the function actually does.

namespace ThreadingTest
{
	static void CalculatePrimeNumbers(int32 UpperLimit)
	{
		//Calculating the prime numbers...
		for (int32 i = 1; i <= UpperLimit; i++)
		{
			bool isPrime = true;

			for (int32 j = 2; j <= i / 2; j++)
			{
				if (FMath::Fmod(i, j) == 0)
				{
					isPrime = false;
					break;
				}
			}

			if (isPrime) GLog->Log("Prime number #" + FString::FromInt(i) + ": " + FString::FromInt(i));
		}
	}
}

I basically want the loop to run on the “SetDictionary” function rather than calculate whether or not int32 is prime

I’ve also never really looked at C++ before now so I know I shouldn’t really be trying this, but I don’t have a choice. xD

Here’s a screenshot of the blueprint as well. I should have included it in the first run through, but I was pretty frustrated when I made this post. xD

If anyone has any advice on how to write this in C++ so I can just call the function that way, I’d be open to that as well. As long as I can still call the function in BP so it can communicate with the rest of the game.

I guess the image capture(r) didn’t like my link…
Here’s the screenshot to the BP: