I'm quite new to multithreading and today I ran into this strange problem. I followed some online tutorials and it seemed to me that what I'm doing is the correct.
So I got this code:
GrammarThreading gThread = new GrammarThreading(this, grammar); Thread thread = new Thread(new ThreadStart(gThread.threadUnloadGrammar)); with it I want to move grammar unloading to another thread, since it takes a couple of seconds. This is how the class of GrammarThreading looks like:
public class GrammarThreading { public MainWindow window { get; set; } public Grammar grammar { get; set; } public GrammarThreading(MainWindow _window, Grammar _grammar) { window = _window; grammar = _grammar; } public void threadUnloadGrammar() { window._recognizer.UnloadGrammar(grammar); } } However, I debugged the code and threadUnloadGrammar() method seems never to be called. I've got no idea what could the problem be so any help will be greatly appreciated. Thanks :)
thread.Start()anywhere?TaskFactoryclass in theSystem.Threading.Tasksnamespace that's worth looking into. It's a very similar creature and has small trade-offs either way, but does allow a nice fluent syntax for chaining events together.