i run two therad , each thread process it's pdf, and each thread thread has it's own GhostscriptProcessor, if i just start one thread there is no problem ,but if i start tow thread, gohstScript.net will give error "error occured when call to 'gsapi_new_instance' is made: -100" and i try version gs64bit and version gs32bit , the result is the same
my code as fellows can anyone help me? thanks a lot.
Thread t1 = new Thread(processPdf);
Thread t2 = new Thread(processPdf);
t1.Start("D:\\T1.PDF");
t2.Start("D:\\T2.PDF");
public static void processPdf(object obj) {
GhostscriptVersionInfo gvi = null;
GhostscriptProcessor ghostscript = null;
try
{
gvi =
GhostscriptVersionInfo.GetLastInstalledVersion(GhostscriptLicense.GPL |
GhostscriptLicense.AFPL, GhostscriptLicense.GPL);
ghostscript = new GhostscriptProcessor(gvi);
string outputPath = obj.ToString();
string input = null;
if (outputPath.Contains("T1")) {
input = @"D:\TestFiles\111.pdf";
}
else {
input = @"D:\TestFiles\222.pdf";
}
string[] args = GetArgs(input, outputPath);
ghostscript.Process(args);
}
catch (Exception ex) {
Console.WriteLine(ex.StackTrace+"|"+ex.Message);
}
}//多线程
private static string[] GetArg(string inputFile, string outputFile)
{
return new[] {
$"gs",
$"-o",
$"{outputFile}",
$"-dNoOutputFonts",
$"-sDEVICE=pdfwrite",
$"{inputFile}",
};
}