protected override void OnStop() { if (_serviceHost != null) { _serviceHost.Close(); InstancesManager.DeleteDynamicLoadingDLL(); _serviceHost = null; } }
/// <summary> /// The main entry point for the application. /// </summary> static void Main() { ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new GhostscriptService() }; ServiceBase.Run(ServicesToRun); InstancesManager.DeleteDynamicLoadingDLL(); }
protected override void OnStart(string[] args) { if (_serviceHost != null) { _serviceHost.Close(); } //Delete previous dynamic loading DLLs if there are any. InstancesManager.DeleteDynamicLoadingDLL(); // Create a ServiceHost for the ConvertToPdfService type and provide the base address. _serviceHost = new ServiceHost(typeof(ConverterService)); // Open the ServiceHostBase to create listeners and start listening for messages. _serviceHost.Open(); }
static void Main() { AllocConsole(); string testFolder = "..\\..\\Tests\\"; string outputFolder = testFolder + "Output\\"; string inputFolder = testFolder + "Input\\"; int numRepeats = 1; if (!System.IO.Directory.Exists(testFolder)) { System.IO.Directory.CreateDirectory(testFolder); } if (!System.IO.Directory.Exists(outputFolder)) { System.IO.Directory.CreateDirectory(outputFolder); } System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(outputFolder); foreach (System.IO.DirectoryInfo dir in di.GetDirectories()) { dir.Delete(true); } foreach (System.IO.FileInfo file in di.GetFiles()) { file.Delete(); } Console.WriteLine("Start Test"); Stopwatch stopWatch = new Stopwatch(); Stopwatch iterationWatch = new Stopwatch(); TimeSpan ts; stopWatch.Start(); ConverterService converter = new ConverterService(); for (int i = 1; i <= numRepeats; ++i) { iterationWatch.Reset(); iterationWatch.Start(); //converter.ConvertPDF2JPG(inputFolder + "Sample.pdf", outputFolder, 72, 72, 1, 1, 72); //converter.ConvertPDF2EPS(inputFolder + "Sample.pdf", outputFolder + i.ToString() + ".ps",1,1); //converter.ConvertEPS2PDF(outputFolder + i.ToString() + ".ps", outputFolder + i.ToString() + ".pdf"); //converter.ConvertEPS2LowResPDF(outputFolder + i.ToString() + ".ps", outputFolder + i.ToString() + "_lowres.pdf"); //converter.ConvertImage2LowResImage(inputFolder + "ImageTest.jpg", inputFolder + i.ToString() + ".jpg"); //converter.ConvertImage2LowResImage(inputFolder + "Sample.TIF", outputFolder + i.ToString() + ".tif"); //converter.ConvertImage2LowResImage(inputFolder + "Sample.jpg", outputFolder + i.ToString() + ".jpg"); //converter.ConvertImage2LowResImage(inputFolder + "Sample.png", outputFolder + i.ToString() + ".png"); //converter.ConvertImage2LowResImage(inputFolder + "Sample.gif", outputFolder + i.ToString() + ".gif"); //converter.ConvertPDF2PNGSingle(inputFolder + "Sample.pdf", outputFolder + "Sample.png", 72, 72, 2, 4); converter.ConvertPDFFolder2PNG(inputFolder, outputFolder, "*.pdf", true, true, 72, 72, 2, 4); iterationWatch.Stop(); ts = iterationWatch.Elapsed; Console.WriteLine("RunTime iteration {0} {1:00}:{2:00}:{3:00}.{4:000}", i, ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds); } stopWatch.Stop(); ts = stopWatch.Elapsed; Console.WriteLine(""); Console.WriteLine("Total Run Time: {0:00}:{1:00}:{2:00}.{3:000}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds); ts = TimeSpan.FromMilliseconds(ts.TotalMilliseconds / numRepeats); Console.WriteLine("Avrag Run Time: {0:00}:{1:00}:{2:00}.{3:000}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds); InstancesManager.DeleteDynamicLoadingDLL(); Console.ReadLine(); /* * Worker workerObject = new Worker(); * Thread workerThread = new Thread(workerObject.DoWork1); * //workerThread.Start(); * * Worker workerObject2 = new Worker(); * Thread workerThread2 = new Thread(workerObject.DoWork2); * //workerThread2.Start(); * * Worker workerObject3 = new Worker(); * Thread workerThread3 = new Thread(workerObject.DoWork3); * //workerThread3.Start(); * * Worker workerObject4 = new Worker(); * Thread workerThread4 = new Thread(workerObject.DoWork4); * //workerThread4.Start(); * * //convert.ConvertFileType("C:\\gs\\PDF\\Folder2\\2Text_graph_image_cmyk_rgb.pdf", "C:\\gs\\JPG\\Folder2", wild.Length, "jpg"); * * convert.ConvertFileTypeNestedFolders(convertFolderPath, targetFolderPath, "*.pdf", "jpg"); * * sw.Stop(); * Console.WriteLine("Elapsed={0}", sw.ElapsedMilliseconds/1000); * * workerThread.Join(); * workerThread2.Join(); */ }