问题描述
大家好
我们正在使用我们自己的类将日志写入Web应用程序的.txt文件。该类所做的是创建一个最大值为no的信号量。当前条目为1.我们使用此信号量获取对日志文件的写入权限。像这样....
Hi everyone
we are writing logs to a .txt file for a web application, using our own class. What the class does is create a semaphore with maximum maximum no. of current entries as 1. we use this semaphore to gain write access to the log file. like this....
private static Semaphore _ExceptionFileLock = new Semaphore(1, 1);
try
{
// Take Hold of File Lock
_ExceptionFileLock.WaitOne();
......
Open the file strea, write, and close....
......
}
catch (Exception objException)
{
// Other Exception
throw objException;
}
finally
{
//Release File Lock
_ExceptionFileLock.Release();
}
现在我想知道的是,一旦我们在IIS上发布它,多个用户点击了这个应用程序,IIS会为此创建一个全局信号量,还是为不同的请求创建不同的信号量对象,导致异常文件正在使用中
信号量上的任何亮点我将非常感谢您对IIS的参考。
谢谢和问候
Pawan
Now what I''d like to know is once we publish it on IIS and multiple users hit this application, will IIS create a global semaphore for this or for different requests will IIS create different semaphore objects resulting in exception "file is alrady in use"
Any light on semaphore with reference to IIS will be greatly appreciated.
Thanks and regards
Pawan
推荐答案
这篇关于asp.net web应用程序中的信号量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!