dmuka3.CS.Simple.Semaphore 1.0.1

Semaphore library.

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.

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);
        }
    }
}

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);
        }
    }
}

  • .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 History

Version Downloads Last updated
1.0.1 222 10/26/2019
1.0.0 118 10/26/2019