9
Answers

How to create background process / tray application

fawzan mohamed

fawzan mohamed

13y
4.8k
1
Hi,
I need to create an application which should search and capture some user specified files. this application should run as a background process or tray application. Do i have to write a windows service for this?
or how could i get this done?? 

Thanks a lot in advance. 
Answers (9)
1
Vulpes

Vulpes

NA 163.6k 1.5m 10y
Well, the Dispose() method only cleans up unmanaged resources such as file handles, database connections etc. It doesn't remove the managed object (x) itself from memory.

The garbage collector (GC) does that when there are no longer any references to the object at a time of its choosing.

Generally speaking, the GC does a good job and you should not try to interfere with its operation. Apart from calling Dispose() if the object implements IDisposable, the only thing you should do is to set object references to null if they are no longer needed and they aren't about to go out of scope anyway as this might enable the GC to clean up the object more quickly.

However, you can force a collection to take place with the static GC.Collect() method and, if you're about to perform a critical operation where you cannot afford the GC kicking in in the middle of it, then you can call this method first. 

Accepted
0
Marc

Marc

NA 230 35.1k 10y
Thanks for the thorough explanation!