users. I'm running into a problem that i can't find an answer for. I'm kind of new to Threading (in C#), and ran into this problem. I have this image editor with effects, but since it ran too slow, i tried to split it up in threads. The problem is that he always runs the "CreatePreview" command with the last item in the list of effects. So if i activated effects: "Black/White","Sature" and "GreenFilter", it will try to create 3 previews with a greenfilter.
Could anyone help me out with this problem?
private void CreatePreviews(string fileName, List<IEffect> effects)
{
    List<Task> tasks = new List<Task>();
    foreach (var effect in effects)
    {
        //previews.Add(effect, CreatePreview(fileName, effect));
        Task task = new Task(delegate()
        {
            string result = CreatePreview(fileName, effect);
            Dispatcher.BeginInvoke(new Action(
            delegate()
            {
                ShowPreview(result, effect.DisplayName);
            }));
        });
        task.Start();
    }
}
 
     
     
     
     
    