954,504 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

_DoWork in backgroundworker

When writing a timeformat in a textbox using the event _TextChanged and when timeformat has reached the written format "HH:MM", the ->RunWorkerAsync() command
should execute and create a file but it seems that the backgroundworker does not execute the code inside.
I wonder why this is not happening, have I missed any part of the process to make that work ?

private: System::Void maskedTextBox1_TextChanged(System::Object^  sender, System::EventArgs^  e) 
{

if( maskedTextBox1->Text->Length == 5 )//When time has format "HH:MM"
{
	 //Put present Time to global variables
	 time_t now = time(0);
	 struct tm* tm = localtime(&now);

	 PresentHour = tm->tm_hour;
	 PresentMinute = tm->tm_min;
	 /*........................................*/
			
	 backgroundWorker1->RunWorkerAsync();//Execute _DoWork
}
		 
}



private: System::Void backgroundWorker1_DoWork(System::Object^  sender, System::ComponentModel::DoWorkEventArgs^  e) 
{
	
	ofstream pf;
	pf.open("C:\\createdfile.txt");
	pf << "abcdefgh";
	pf.close();

}
Liszt
Junior Poster
122 posts since Oct 2008
Reputation Points: 33
Solved Threads: 6
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You