0

I have a window (C#) application (only .exe file, no code) which uses a thread. If my application is closed mean I am not using that application. Is thread working backword at this time or not?

My Problem is that I am transferring a file from one drive to another drive at a particular time using timer thread class, at that particular time application is closed.

File will transfer or not?

4
  • 1
    It depends what you mean by "application is closed". A thread will exist inside a process, but your applications process can continue running even though the UI has closed. In other words, a GUI application can be "closed", but continue to run. Open task manager to check for the process and see what happens when you close the UI.
    – Snixtor
    Apr 3, 2013 at 9:50
  • but if the system(computer) is in shutdown mode Apr 3, 2013 at 10:08
  • Sorry could you clarify? It sounds like you're asking if a thread continues working after the PC is turned off.
    – Snixtor
    Apr 3, 2013 at 10:39
  • Check by Task Manager
    – Xaqron
    Apr 9, 2013 at 21:02

3 Answers 3

1

No it wont. The thread was started in application and if application is closed all threads in it are killed.

1

Any threads that you start in your program, prevent the application from terminating, until all the treads have exited their thread proc function, or have abort() called on them.

To examine the exact way the timer thread class works, run the demo code that is located on the MSDN

http://msdn.microsoft.com/en-GB/library/ms149618.aspx

As people have pointed out, set background threads will not prevent application from termination, however, having a thread as a background thread, would not achieve what the op wanted.

1
  • @LogieUrquhart yes, that's for 'foreground' threads. Threads from pool or manually created background threads are aborted when process exits. Please correct your answer Apr 3, 2013 at 10:04
0

No, threads only exist if your application is running. You need to create a completely separate background process (not just a background thread) if you want something to continue after your main application exits

2
  • Even if a thread is specified background-type, it too will terminate when the application is closed.
    – MoonKnight
    Apr 3, 2013 at 9:53
  • @Killercam I think he may have been referring to spinning up an entirely new process, not just a new thread. Apr 3, 2013 at 9:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.