mardi 21 avril 2015

Function doesn't return value from another thread

I'm working with multithreading and faced with one strange moment. I have following code:

var advancedSearchView = ObjectFactory.ShowView<IGeneralReportAdvancedSearchView>()

In this case code works fine. But when I try to use BackgroundWorker fuction ShowView doesn't return any value.

BackgroundWorker backgroundWorker = new BackgroundWorker();

private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
{
   var simpleView= ObjectFactory.ShowView<IGeneralReportSimpleView>();
}

string ShowView<T>()
{
return typeof(T).Name;
}

My backgroung worker calling from the same method as advancedSearchView

backgroundWorker.RunWorkerAsync();

Could you be so kind to advise how to solve current problem?

Aucun commentaire:

Enregistrer un commentaire