I am trying to set the apartment state on a task but see no option in doing this. Is there a way to do this using a Task?
for (int i = 0; i < zom.Count; i
You could for example make a new task as follows:
try
{
Task reportTask = Task.Factory.StartNew(
() =>
{
Report report = new Report(this._manager);
report.ExporterPDF();
}
, CancellationToken.None
, TaskCreationOptions.None
, TaskScheduler.FromCurrentSynchronizationContext()
);
reportTask.Wait();
}
catch (AggregateException ex)
{
foreach(var exception in ex.InnerExceptions)
{
throw ex.InnerException;
}
}