FileSystemWatcher and task

  • Thread starter Thread starter neonash
  • Start date Start date
N

neonash

Guest
Hi

I have the following code to search files in 2 folders..

public async Task ProcessFiles()
{
var processVivere = MonitoringVivere();
var processOfficeBanking = MonitoringSantanderConsumer();

await Task.WhenAll(processVivere, processOfficeBanking);
}

#region Privates

public async Task MonitoringVivere()
{
var fileSystemWatcher = new FileSystemWatcher
{
Path = Vivere.RutaIn
};

fileSystemWatcher.Created += FileSystemVivereToOfficeBanking_Created;
fileSystemWatcher.EnableRaisingEvents = true;

await Task.Delay(1);
}

public async Task MonitoringSantanderConsumer()
{
var fileSystemWatcher = new FileSystemWatcher
{
Path = OfficeBanking.RutaOut
};

fileSystemWatcher.Created += FileSystemOfficeBankingToVivere_Created;
fileSystemWatcher.EnableRaisingEvents = true;

await Task.Delay(1);
}

If I convert FileSystemVivereToOfficeBanking_Created to a async /await method... I received an error.



private void FileSystemVivereToOfficeBanking_Created(object sender, FileSystemEventArgs e)
{
ProcessVivereToOfficeBanking(e);

}



The error is:

Task GetReleasesQueryHandler.FileSystemOfficeBankingToVivere_Created(object, FileSystemEventArgs)' has the wrong return type Pionner.Releases.Application C:\Users\User\Desktop\Santander.Pionner.Converters\Pionner.Releases.Application\10.Application\Querys\GetReleasesQueryHandler.cs


How can I change FileSystemVivereToOfficeBanking_Created and FileSystemOfficeBankingToVivere_Created as async/awt methods?

Continue reading...
 
Back
Top