Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Multithreading with Classes in MFC

Avatar of mr_stevie
mr_stevieFlag for Australia asked on
C++Visual C++.NETSystem Programming
3 Comments1 Solution687 ViewsLast Modified:
Hello,

I am having trouble implementing multi-threading into my program.
At the moment, I am reading the MSDN libraries but it does not make much sense to me.

To start off, I have two different classes that will output to two different files.

For example, a simple example class is given below.

At the moment, I have them outputting one after the other. Although performance isn't really an issue at the moment, I will be eventually be dealing large amounts of data and would like the classes to be doing calculations and output independently on different threads.

I intended to use a Worker Thread but I am unsure how what parameters to pass through to the AfxBeginThread() function.

If anyone could provide any assistance, will be greatly appreciated!

Thank you in advance!
void CLASSA::output()
{
	ofstream output( output1.txt );

	for( unsigned int x = 0; x < 100; x++ )
	{
		output << x << "\n";
	}

	output.close();
}

void CLASSB::output()
{
	ofstream output( output2.txt );

	for( unsigned int x = 0; x < 100; x++ )
	{
		output << x << "\n";
	}

	output.close();
}
ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscowFlag of Switzerland imageFreelance programmer / Consultant

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answers