0

I'm working on a console application that tries to download some files from a website by logging in and then copying the files to a shared folder.

Since its very much possible that the user might click on close button manually or tries to end the process manually somehow, is there a way I can detect this?

abatishchev
  • 98,240
  • 88
  • 296
  • 433
akhil
  • 1,202
  • 3
  • 21
  • 43

2 Answers2

2

Create an empty project instead. So you will have a "hidden process", with no UI which a user will try to close.

abatishchev
  • 98,240
  • 88
  • 296
  • 433
  • this is an idea but it will consume and allocate unnecessary resources, this is a job for a windows service, do you agree? – Freeman Jul 05 '12 at 12:05
  • @Freeman: I think it depends on several factors: how does start the process: should it start on OS boot, or by user or another app manually? how often should it run: once or periodically? – abatishchev Jul 05 '12 at 12:32
  • yes but the start time was not the point, even the number of loaded assemblies is bigger on a windows form project then in a service project as the last one does not need the the GUI libraries loaded to memory. – Freeman Jul 05 '12 at 12:41
  • @Freeman: If you don't create a form, you don't need to load these assemblies, you even can remove it from references. ProjectType=Windows just directs Windows do not create a console for this process. – abatishchev Jul 05 '12 at 12:46
  • I don't want to comment this further without a reason, but if you want a project that does not require some assemblies why not just make one, instead of making a project with more assemblies and the manually removing its references? – Freeman Jul 05 '12 at 12:54
  • @Freeman: You're right, you can create just an empty project. – abatishchev Jul 05 '12 at 13:08
  • Even better i can create a project that suits my needs. – Freeman Jul 05 '12 at 13:16
1

It rather recommended that you make this a windows service application so it will run as a service that implies no user interaction at all with the application.

Freeman
  • 5,691
  • 3
  • 29
  • 41