I'm developing a simple application which should be able in process different tasks using a plug-in architecture, so each plug-in is a DLL library file and contains a class which implements a provided interface as follows.
public interface ITaskProcessor
{
void Execute(FileStream input, FileStream output);
}
I suppose that the Execute
method of a certain plug-in will be invoked only if the input file exists, so I created the following class in my plug-in architecture.
public class TaskProcessorContext
{
private ITaskProcessor TaskProcessorInstance;
// ...
void Execute(string inputDataFilename, string outputDataFilename)
{
using (FileStream input = File.OpenRead(inputDataFilename), output = new FileStream(outputDataFilename, FileMode.Create))
{
this.TaskProcessorInstance.Execute(input, output);
}
}
}
The overall functioning of my application should provide that a BasicHttpBinding
web service receives the file containing a task and the unique name of the plug-in that should process the task:
- the received file is temporarily stored in a specific directory, then the web service should notify the completion of the writing of the file, so that the task can be queued for execution;
- an identifier is associated to the task, so it will be possible to know its processing state, for example using a
Dictionary
; - when the task is completed or if it is encoured an error during the processing, these events should be notified to the web service.
How could manage this communication between the WCF service and the thread that processes the task?