Thursday, March 19, 2015

Make An Mfc Worker Thread

Threads are the objects that accomplish multi-tasking viable. Threads, Everyone similar to a "bit slice" or seperate government of the running programme, contrive the phantasm that multiple users can fist a server practice. The Microsoft Foundation Troop Lib encapsulates threads via the CWinThread party, which supports User and Employee threads that fall in the background. In a few steps, you can make a simple program utilizing a Worker Thread.


Instructions


1. Start Microsoft Visual Studio. Create a dialog-based MFC project by clicking "File" from the upper menu and then "New." After clicking the "Projects" tab, select "MFC AppWizard(exe)" and type "WThread" in the "Project name:" edit box. Click "OK." In the next wizard screen, select "Dialog based," then click "Finish" and "OK." The wizard generates a default dialog box and its associated source files.


Copy/paste the following source code carry on of the file:void ThreadProcess(LPVOID param) {CFile f;2. Make a function that will act as the Worker thread for this MFC tutorial. Open the WorkerThreadDlg.cpp file by expanding the "Source Files" folder in the left pane and double-clicking the file.




f.Open("proof.txt", CFile::modeCreate | CFile::modeWrite);


CString str;


for(int i=0; i