Reputation: 259
i am programming in windows application using c#.
i want to close a application using this.close();
my application windows are closed.but i try to delete that application file,it shows "the file using by an another process"?
note:i am also using backgroundrunner in that application.if it make any problem for the above issue?
Upvotes: 0
Views: 761
Reputation: 56
Try calling this function before you exit the main method.
The workerThread is the background worker
public void Abort()
{
if (workerThread != null)
{
workerThread.Abort();
workerThread = null;
}
}
Upvotes: 1
Reputation: 5223
when you use this.Close()
, you are closing the window form but not the application.
The background runner you issued in application will still running behind the scene even you explicitly close the form. That's why you are getting the message.
you also might need to check type of background worker if is busy with the processes and handle it gracefully to terminate/complete the request before closing the application. The Application.Exit
The foreground threads will continue from terminating, the background will not.
Upvotes: 1
Reputation: 53593
Try closing your application using Application.Exit.
Informs all message pumps that they must terminate, and then closes all application windows after the messages have been processed.
Upvotes: 1