Liszt 23 Junior Poster

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();

}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.