我运行两个therad,每个线程处理它的pdf,每个线程线程都有它自己的GhostscriptProcessor,如果我只启动一个线程没有问题,但是如果我启动两个线程,gohstScript.net会给出错误“调用时发生错误” 'gsapi_new_instance' 是:-100" 我尝试版本 gs64bit 和版本 gs32bit ,结果是一样的
我作为研究员的代码有人可以帮助我吗?多谢。
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}",
};
}