gpt4 book ai didi

c# - 我可以使用响应式扩展来排队调用 Windows 服务吗?

转载 作者:行者123 更新时间:2023-11-30 21:08:33 24 4
gpt4 key购买 nike

我有一个窗口服务正在调用一个非线程安全的 api (ghostscript) 将 pdf 转换为图像,所以我需要确保一次调用一个方法调用,但将所有可能来自各种调用的调用排队应用实例。

应用程序 -> Windows 服务 -> ghostscript

最佳答案

给你:

var eventLoop = new EventLoopScheduler();

IObservable<Unit> QueueAnItem(string input)
{
return Observable.Start(() => CallGhostScriptAndWaitForItToFinish(input), eventLoop);
}

QueueAnItem("Foo").Subscribe(
x => Console.WriteLine("It Finished!"),
ex => Console.WriteLine("Something Bad Happened: {0}", ex.ToString());

关于c# - 我可以使用响应式扩展来排队调用 Windows 服务吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9606575/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com