我正在尝试调解一个小的Windows服务,使其在启动期间等待来自另一个进程的信号.当然,我知道这种方法可能(甚至会)有时会导致服务启动超时.事实并非如此.
问题是名为System.Thread.Sempaphore我用于调解目的.使用以下构造在其他地方创建和获取信号量.没有更改GC有它,因为我明确地在给定的行下方执行测试以进行测试.
Boolean newOne;
System.Threading.Semaphore rootSemaphore =
new System.Threading.Semaphore(1, 1, "DummyServiceSemaphore", out newOne);
Run Code Online (Sandbox Code Playgroud)
上面的代码显然效果很好.以下代码在调试模式或控制台应用程序下执行时效果很好:
Boolean createdNew;
System.Threading.Semaphore semaphore =
new System.Threading.Semaphore(1, 1, "DummyServiceSemaphore", out createdNew);
if (createdNew)
throw new Exception("That's not what we wanted");
Run Code Online (Sandbox Code Playgroud)
作为Windows服务的一部分执行时,完全相同的代码失败:
static class Program
{
static void Main(string[] args)
{
Boolean createdNew;
System.Threading.Semaphore semaphore =
new System.Threading.Semaphore(1, 1, "DummyServiceSemaphore", out createdNew);
if (createdNew)
throw new Exception("That's not what we wanted");
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[] { new Dummy() };
ServiceBase.Run(ServicesToRun);
}
}
Run Code Online (Sandbox Code Playgroud)
所以,请寻求帮助.
PS:我一直在尝试使用Mutex,但是还有另外一个问题 - …
问题是我一直在一个相当简单的查询上获得 seq 扫描,这是一个非常简单的设置。我究竟做错了什么?
constraint_exclusion = partition这是创建语句:
CREATE TABLE A (
K int NOT NULL,
X bigint NOT NULL,
Date timestamp NOT NULL,
fy smallint NOT NULL,
fz decimal(18, 8) NOT NULL,
fw decimal(18, 8) NOT NULL,
fv decimal(18, 8) NULL,
PRIMARY KEY (K, X)
) PARTITION BY LIST (K);
CREATE TABLE A_1 PARTITION OF A FOR VALUES IN (1);
CREATE TABLE A_2 PARTITION OF A FOR VALUES IN …Run Code Online (Sandbox Code Playgroud) postgresql query-optimization database-partitioning database-indexes postgresql-11