A really simple multithread wrapper with a queue of objects to execute.
Features:
[Only registered and activated users can see links. Click Here To Register...]
Example use: (Also included in the download.)
Good luck.
Note:
FinishQueueState(); has to be called in the end of the execution no matter what. It will reset the queuestate, so it will be executed by the thread next time.
Features:
Download:Quote:
-Multithreading
-Execute a queue of objects
-Never a duplicate execution
-Simple and fast
[Only registered and activated users can see links. Click Here To Register...]
Example use: (Also included in the download.)
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using QueLib.QueueThreading;
namespace ConsoleApplication1
{
public sealed class Player : ActionQueueObject
{
public Player(string Name)
: base()
{
this.Name = Name;
this._Event = new ActionQueueEvent(ActionQueueExecute);
}
public string Name;
private ActionQueueEvent _Event;
public override ActionQueueEvent Event
{
get
{
return _Event;
}
}
public void ActionQueueExecute()
{
Console.WriteLine("Something to execute {0}", Name);
FinishQueueState();
}
}
public sealed class PlayerThread : ActionQueue
{
public PlayerThread(int Interval)
: base(Interval)
{
}
public Dictionary<uint, Player> Players = new Dictionary<uint, Player>();
public override ActionQueueObject[] queueObjects
{
get
{
return Players.Values.ToArray();
}
}
}
class Program
{
static PlayerThread PlayerThread;
static void Main(string[] args)
{
PlayerThread = new PlayerThread(5000);
PlayerThread.Players.Add(0, new Player("LOL"));
PlayerThread.Prepare();
PlayerThread.Start();
while (true)
Console.Read();
}
}
}
Note:
FinishQueueState(); has to be called in the end of the execution no matter what. It will reset the queuestate, so it will be executed by the thread next time.