I have set up a process to create new tasks to handle file processing. A problem arised where I received and unhandled exception error and just clicking on the continue button, the main process continued to run. Now I also found that within the child task I was having a file conflict error and as the tasks run as separate .exe i was under the impression that everything would have been thread safe. So for the first issue here is the task creation in the main process..GProcess is a complete project on its own consisting of 6 classes. This is added as a class library reference to the main process class form1
Public Class Form1
..Private parser as GProcess.module = new GProcess.module()
dim factory as new taskfactory
factory.startnew(address of parser.main)
try
task.waitall()
catch ae as aggregateexception
for each ex in ae.innerexceptions
logs.insert(ex.message.tostring)
next
finally
parser.ctsources.cancel()
end try
now I got the aggregateexception thing from msdn and not sure how to implement it but basically what i want to is cancel the task that caused the exception and contiue running all other tasks and capture the file that the cancelled task was working on and save the name to my logs or if possible restart that task with the file it was working on..
Now for the second issue I have a xmlwriter being created when a class is accessed by the task which should create its own instance of it so not sure why there is a clash but if it does happen, does the task / thread just cancel or does it wait to access the file.
....
public class filecleaner
private xmlfile as string = directoryPath & filename
private xwriter as xmltextwriter = new xmltextwriter(xmlfile,nothing)
....