static void Main(string[] args) { _doneEvent = new ManualResetEvent(false); _numBusy = 2; // variable to store video file extension string sVideoFileExt; // are we using WMV or AVI video format for output bool isWMV = false; // if is WMV then use .wmv extension if (isWMV) { sVideoFileExt = ".wmv"; } else // else use AVI { sVideoFileExt = ".avi"; } // Start two conversion threads Console.WriteLine("Start first thread..."); ThreadData threadData1 = new ThreadData(new string[] { "slide1.jpg", "slide2.jpg", "slide3.jpg" }, "Part1" + sVideoFileExt); ThreadPool.QueueUserWorkItem(DoWork, threadData1); Console.WriteLine("Start second thread..."); ThreadData threadData2 = new ThreadData(new string[] { "slide4.jpg", "slide5.jpg", "slide6.jpg" }, "Part2" + sVideoFileExt); ThreadPool.QueueUserWorkItem(DoWork, threadData2); // Wait for both threads finished _doneEvent.WaitOne(); // Join generates parts Console.WriteLine("Join parts into the final video file..."); ImageToVideo converter = new ImageToVideo(); if (isWMV) { converter.JoinWMVFiles("Part1" + sVideoFileExt, "Part2" + sVideoFileExt, "Result" + sVideoFileExt); } else { converter.JoinAVIFiles("Part1" + sVideoFileExt, "Part2" + sVideoFileExt, "Result" + sVideoFileExt); } // Open the output video file in default media player Process.Start("Result" + sVideoFileExt); Console.WriteLine("Done. Press any key to continue..."); Console.ReadKey(); }