NolanHodge.Threader 1.0.0

DPackage for running Tasks in parallel like they are System.Threading.Threads.

Install-Package NolanHodge.Threader -Version 1.0.0
dotnet add package NolanHodge.Threader --version 1.0.0
<PackageReference Include="NolanHodge.Threader" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NolanHodge.Threader --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: NolanHodge.Threader, 1.0.0"
For F# scripts that support #r syntax, copy this into the source code to reference the package.

Threader

Threader is a nuget package for running Tasks in parallel like they are System.Threading.Threads.

This package is optimized for long running operations. The UWP 10.0 framework does not allow the usage of Threads, but rather Tasks.
Tasks are not treated like Threads and a user will not get a desired result using them in that manner.

Threader allows users to execute long and short running operations in the same manner as Threads.

Example

  using NolanHodge.Threader;
  
  // A Class that satisfies the IThreader interface.
  class Button : IThreader
  {
      Action<object> Draw;
      public ButtonData(Canvas canvas, Action<object> action)
      {
          Canvas = canvas;
          Label = label;
      }

      public string Name()
      {
          return Canvas.Name;
      }

      public void Action()
      {
          Draw(this);
      }
  }

  // The Application requiring long running operations.
  class Application
  {
    Threader T = new Threader(); 
    void Init()
    {
        foreach (string name in canvases)
        {
            T.Spawn(new Button(name, Diagnose))
        }
    }

    // Kill the Threaders pool.
    void OnClose()
    {
      T.KillAll();
    }

    // Use the IThreader object in parallel, handling stops.
    void Diagnose(Button b)
    {
        while (true)
        {
            if (T.Killed(b))
            {
                return;
            }

            OnMainThread(Draw(b));
        }
    }
}

Threader

Threader is a nuget package for running Tasks in parallel like they are System.Threading.Threads.

This package is optimized for long running operations. The UWP 10.0 framework does not allow the usage of Threads, but rather Tasks.
Tasks are not treated like Threads and a user will not get a desired result using them in that manner.

Threader allows users to execute long and short running operations in the same manner as Threads.

Example

  using NolanHodge.Threader;
  
  // A Class that satisfies the IThreader interface.
  class Button : IThreader
  {
      Action<object> Draw;
      public ButtonData(Canvas canvas, Action<object> action)
      {
          Canvas = canvas;
          Label = label;
      }

      public string Name()
      {
          return Canvas.Name;
      }

      public void Action()
      {
          Draw(this);
      }
  }

  // The Application requiring long running operations.
  class Application
  {
    Threader T = new Threader(); 
    void Init()
    {
        foreach (string name in canvases)
        {
            T.Spawn(new Button(name, Diagnose))
        }
    }

    // Kill the Threaders pool.
    void OnClose()
    {
      T.KillAll();
    }

    // Use the IThreader object in parallel, handling stops.
    void Diagnose(Button b)
    {
        while (true)
        {
            if (T.Killed(b))
            {
                return;
            }

            OnMainThread(Draw(b));
        }
    }
}

Dependencies

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.0 167 11/17/2019