資源簡介
class Program
{
static void Main(string[] args)
{
Semaphore seamphore = new Semaphore(5, 5, "SemaphoreExample");
seamphore.WaitOne();
Console.WriteLine("Seamphore 1");
seamphore.WaitOne();
Console.WriteLine("Seamphore 2");
seamphore.WaitOne();
Console.WriteLine("Seamphore 3");
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Linq;
using?System.Text;
using?System.Threading.Tasks;
using?System.Threading;
//WYF:另外,可以給信號量設置一個名稱,這個名稱是操作系統可見的,因此,可以使用這些信號量來協調跨進程邊界的資源使用。
//WYF:運行兩個這樣的同一個程序,你講看到這樣的結果,在第二個運行的程序示例中,會將線程阻塞在第三個信號量上。
namespace?Semaphore1
{
????class?Program
????{
????????static?void?Main(string[]?args)
????????{
????????????Semaphore?seamphore?=?new?Semaphore(5?5?“SemaphoreExample“);
????????????seamphore.WaitOne();
????????????Console.WriteLine(“Seamphore?1“);
????????????seamphore.WaitOne();
????????????Console.WriteLine(“Seamphore?2“);
????????????seamphore.WaitOne();
????????????Console.WriteLine(“Seamphore?3“);
????????????Console.ReadLine();?//WYF:?因為執行到這,會等待輸入數據,所以下面的一行代碼沒有執行。
????????????seamphore.Release(
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????187??2014-08-01?11:38??Semaphore1\Semaphore1\App.config
?????文件???????5120??2014-09-17?10:57??Semaphore1\Semaphore1\bin\Debug\Semaphore1.exe
?????文件????????187??2014-08-01?11:38??Semaphore1\Semaphore1\bin\Debug\Semaphore1.exe.config
?????文件??????11776??2014-09-17?10:57??Semaphore1\Semaphore1\bin\Debug\Semaphore1.pdb
?????文件??????22984??2014-11-10?13:29??Semaphore1\Semaphore1\bin\Debug\Semaphore1.vshost.exe
?????文件????????187??2014-08-01?11:38??Semaphore1\Semaphore1\bin\Debug\Semaphore1.vshost.exe.config
?????文件????????490??2012-06-06?02:06??Semaphore1\Semaphore1\bin\Debug\Semaphore1.vshost.exe.manifest
?????文件???????6613??2014-08-14?14:28??Semaphore1\Semaphore1\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件????????921??2014-11-10?13:29??Semaphore1\Semaphore1\obj\Debug\Semaphore1.csproj.FileListAbsolute.txt
?????文件???????1753??2014-09-17?10:57??Semaphore1\Semaphore1\obj\Debug\Semaphore1.csprojResolveAssemblyReference.cache
?????文件???????5120??2014-09-17?10:57??Semaphore1\Semaphore1\obj\Debug\Semaphore1.exe
?????文件??????11776??2014-09-17?10:57??Semaphore1\Semaphore1\obj\Debug\Semaphore1.pdb
?????文件??????????0??2014-08-01?11:38??Semaphore1\Semaphore1\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
?????文件??????????0??2014-08-01?11:38??Semaphore1\Semaphore1\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
?????文件??????????0??2014-08-01?11:38??Semaphore1\Semaphore1\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
?????文件???????1164??2014-08-01?14:05??Semaphore1\Semaphore1\Program.cs
?????文件???????1364??2014-08-01?11:38??Semaphore1\Semaphore1\Properties\AssemblyInfo.cs
?????文件???????2561??2014-08-01?11:38??Semaphore1\Semaphore1\Semaphore1.csproj
?????文件????????920??2014-08-01?11:38??Semaphore1\Semaphore1.sln
????..A..H.?????34816??2014-11-07?17:50??Semaphore1\Semaphore1.v11.suo
?????文件????????206??2014-09-17?11:00??Semaphore1\說明WYF.txt
?????文件????????187??2014-08-01?14:07??Semaphore2\Semaphore2\App.config
?????文件???????5632??2014-09-17?11:04??Semaphore2\Semaphore2\bin\Debug\Semaphore2.exe
?????文件????????187??2014-08-01?14:07??Semaphore2\Semaphore2\bin\Debug\Semaphore2.exe.config
?????文件??????13824??2014-09-17?11:04??Semaphore2\Semaphore2\bin\Debug\Semaphore2.pdb
?????文件??????22984??2014-11-07?10:08??Semaphore2\Semaphore2\bin\Debug\Semaphore2.vshost.exe
?????文件????????187??2014-08-01?14:07??Semaphore2\Semaphore2\bin\Debug\Semaphore2.vshost.exe.config
?????文件????????490??2012-06-06?02:06??Semaphore2\Semaphore2\bin\Debug\Semaphore2.vshost.exe.manifest
?????文件???????6613??2014-08-01?15:54??Semaphore2\Semaphore2\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
?????文件????????976??2014-11-07?10:08??Semaphore2\Semaphore2\obj\Debug\Semaphore2.csproj.FileListAbsolute.txt
............此處省略30個文件信息
- 上一篇:C# ftp文件上傳 源碼
- 下一篇:winform圖片輪播 圖片滾動源碼
評論
共有 條評論