dmuka3.CS.Simple.Semaphore 1.0.1

.NET Core 3.0
Install-Package dmuka3.CS.Simple.Semaphore -Version 1.0.1
dotnet add package dmuka3.CS.Simple.Semaphore --version 1.0.1
<PackageReference Include="dmuka3.CS.Simple.Semaphore" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add dmuka3.CS.Simple.Semaphore --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: dmuka3.CS.Simple.Semaphore, 1.0.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install dmuka3.CS.Simple.Semaphore as a Cake Addin
#addin nuget:?package=dmuka3.CS.Simple.Semaphore&version=1.0.1

// Install dmuka3.CS.Simple.Semaphore as a Cake Tool
#tool nuget:?package=dmuka3.CS.Simple.Semaphore&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

dmuka3.CS.Simple.Semaphore

You can manage multiple "Thread" on application server using this library. So the "Thread Count" on server is always fix.

Public Variables

CoreCount

"Thread Count" for actions on server.

public int CoreCount { get; }

Disposed

Is the current instance dispose?

public bool Disposed { get; }

Started

Was the current instance start?.

public bool Started { get; }

Public Methods

Start

This is for start to current instance

public void Start()

AddAction

The current instance add to queue.

public void AddAction(Action action)

Dispose

Is the current instance dispose?

public void Dispose()

Example Usage

using System;
using System.Threading;

namespace dmuka3.CS.Simple.Semaphore.TestsConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("===== Muhammet Kandemir ======");
            Console.WriteLine("Welcome dmuka3.CS.Simple.Semaphore Tests!");

            // Create instance new semphore
            // This instance will have 4 core(Thread)
            ActionQueue semaphore = new ActionQueue(coreCount: 4);
            // Start semaphore as async
            semaphore.Start();

            var rowIndex = 0;
            // This thread is for add 10 action per 5 second
            // And each action wait 1 second after complate
            new Thread(() =>
            {
                while (true)
                {
                    for (int i = 0; i < 10; i++)
                    {
                        semaphore.AddAction(() =>
                        {
                            Console.WriteLine("Row Index = {0}", ++rowIndex);
                            Thread.Sleep(1000);
                        });
                    }

                    Thread.Sleep(5000);
                }
            }).Start();

            while (true)
                Thread.Sleep(1);
        }
    }
}
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp3.0 netcoreapp3.1
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 3.0

    • No dependencies.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on dmuka3.CS.Simple.Semaphore:

Package Downloads
dmuka3.CS.Simple.RamDb

Package Description

dmuka3.CS.Simple.Queuing

Package Description

dmuka3.CS.Simple.RemoteIO

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 655 10/26/2019
1.0.0 248 10/26/2019