Stop/cancel active file processing in C# - c#

I have an Windows service.It uses Filewatcher API to watch for any new files and start processing the file.
Suppose If i want to stop the file processing during runtime (Note I want to stop the active file processing)how can I do that from any external windows application.
Note: Already I am communicating with the windows service from the external windows application

Communicate to the windows service to stop processing and set FileSystsemWatcher.EnableRaisingEvents to false. When you want to continue processing, communicate to the service and set it back to true.
Without more detail about how you're actually communicating between processes, I can't provide much more detail.

If you external application is a .NET windows application, please refer to the following SO Question
How to send a custom command to a .Net windows Service from.Net code?

Related

What .NET project/service to use for a background app that runs all the time?

I have to make a program that watches a location on a computer for files and then converts them when new files get put into a specific folder.
Now my question is what kind of Project would be most appropriate for this?
Is ASP.NET MVC Web Application a good choice or would I be better of doing a Windows Service or WCF Service or even Console App?
My app needs to run on the same server as another MVC app already runs, and I need to access some database to keep track of what files I have converted.
You could utilize Windows task scheduler to periodically run an exe file. In this case the project would be a console app.
A better solution would be to use Windows service. See comments from David & as.if.i.code (tnx btw, you learn something new every day :)

Communication between service and application And also to trigger the application with GUI

I have developed an application which does periodical jobs. It runs as windows service in background and manages jobs. I want to trigger another application with GUI from service application when any error notification needs to be given to user. So after seeing err message user will give some response. So now service application (running as service) should do some work based on user response in GUI application (with interface). User response should be communicated to the service application.
So my requirement is
Application running as service should be able to trigger another application with GUI (its sufficient if triggering happens only when users are logged in)
Communication between an application running as service and application with GUI.
I saw many links about communication between service and application. Named pipes requires .net 3.5 and above, but I want my application to work in .net 2 alone. Writing to a txt file and reading it is last option for me as it is not the best method.
So how it can be done? Please give me ideas to start with.

Multi project application, provide send information between applications

I am writing a service based application, and a UI application within it.
I am using Event Logs to log my error, but some of these errors are critical and user should be aware of.
What I need is to check if The UI application (Windows Application Project) is available, and running... if it's running send the error directly to the UI through a service based application (Windows Service Project).
Now, what to do? There are two step I should take, first check if UI is running, second send info like a class instance or a string or binary data (like using serialize) to the UI and UI receive it.
I think the two applications of yours can interact using the Socket mechanism.
And check this for the "is running" bit:
Checking if my Windows application is running
If you don't mind adding a new dll to your project I suggest to take a look at log4net. There is an appender for remoting, RemotingAppender that fit perfectly your needing. You just need to find some samples on how to implement the "receiver" in your UI app. As an additional benefit, you can use the same library to append in the EventLog, or on a file and so on.

Managing Download File By Using Win Services?

i am trying to make a window service that will monitor and manage download files from different web pages.....
can some one give me direction where should i start looking ......
currnetly i am trying to understand nagios monitoring windows http://nagios.sourceforge.net/docs/3_0/monitoring-windows.html in which they have given some details related to my work
the thing which i have to do is ,
monitor and manage download file
give a custom name to the download file at saving time
and display save dialog box for specifying the location
currently i am making window service on Win XP but i would like this service to run also on other Win Operation Systems too so do i have to do some special setting for making it compatiable with other windows operation systems ??
thanks in advance
Regards,
NewbieFreak
A .NET windows service will run on any windows platform that supports and has the runtime your service targets installed on it.

Starting a windows application from a windows service

I am trying to start a windows application from a windows Service using the below code
Process.Start(#"filename.exe");
In windows 7 I receive a popup that says, "A program running on this computer is trying to display a message"
You cannot start an interactive application from a Windows Service. This was changed in Windows Vista and 7.
Some other advice was given in this Stack Overflow answer on the same subject.
When I've needed to do this, I had to change my Windows Service to a Console Application, and invoked it in that manner.
A work-around I found for this issue was to use the windows task scheduler. You can schedule the application to run some amount of seconds later by creating a batch file.
At my previous company we had this issue and we wrote a console app that ran in the sys tray and acted as a bridge from the service to the desktop. Basically via remoting (I'd use WCF now of course) we let the service request that the console app start up another application.

Categories

Resources