|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Threading;
namespace Leaf.Parallel
{
public class NQueue
{
List<NResult> taskList = new List<NResult>();
static NQueue instance = new NQueue();
NQueue()
{
}
public static NQueue Instance
{
get
{
return instance;
}
}
public List<NResult> TaskList
{
get
{
return taskList;
}
}
public void EnQueue(NResult result)
{
if (taskList.Contains(result) || result.CallbackMode != CallbackMode.Queue)
{
return;
}
lock (taskList)
{
taskList.Add(result);
}
}
public void Update()
{
foreach (NResult var in taskList)
{
if (var.IsReady())
{
var.Wait();
}
}
lock (taskList)
{
taskList.RemoveAll(delegate(NResult item){return item.IsDone();});
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Leaf is a software developer based in ShangHai China.
My major programming languages are C#/C++.
I am very interested in distributed system design and rich client development.
Current I am working on
NParallel.