Public delegate void FileChangeDelegate ();
Place called
Private void RegisterFileWatch (FileReadRequest request, FileChangeDelegate onChanged)
{
FileWatch. Changed -=new FileSystemEventHandler (onChanged);//here
}
//new FileSystemEventHandler need such parameters method agent (object source, FileSystemEventArgs e)
//is there any way to further under the packaging, let the incoming onChanged don't need to define the parameters?
CodePudding user response:
You this writing is not only a trouble, and the object (logical) is incorrect,First of all, the traditional method of a complete statement of registration, cancellation method:
private void test (object sender, EventArgs e)[/code] c # compiler realized here method is a static method,
{
Cs. MessageReceived -=Cs_MessageReceived;
}
[code=csharp] private void Cs_MessageReceived (object sender, MessageReceivedEventArgs r)
{
.
}
And the delegate object generated by the dynamic, you will need to manually save your code, for example:
Action
Here, you'll have to entrust the statement as object, and then use "accurate object instance" to register, log off,