I have in my code two same and big pieces of code, so i create a method and put it there. I call the method two times in my code, the first time normally and the second time i want to call it from doWork event (background worker). The problem is that when it executes (in doWork) my program stops responding... So my question is.How can i call a method from doWork event?
Edit: Some code
private void parseHtmlFile(string file)
{
// here i parse an html file and fill some arraylists.
}
// this is the event where i call method on click
private void MenuItem_NewPr(object sender, RoutedEventArgs e)
{
parseHtmlFile(file);// in this case program works well.
}
// do work
worker.DoWork += (s, e) =>
{
var file = e.Argument as string;
parseHtmlFile(file);// in this case program stop responding.
}
Edit 2: I changed some thing in method and now it doesn't crash, but i have another problem now. The dowork method doesn't executes code which exists below my method call statement. I put a breakpoint there and never goes there...