using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace MinecraftClient
{
public class TaskWithResult
{
private Delegate Task;
private AutoResetEvent ResultEvent = new AutoResetEvent(false);
public object Result;
public TaskWithResult(Delegate task)
{
Task = task;
}
///
/// Execute the delegate and set the property to the returned value
///
/// Value returned from delegate
public object Execute()
{
Result = Task.DynamicInvoke();
return Result;
}
///
/// Block the program execution
///
public void Block()
{
ResultEvent.WaitOne();
}
///
/// Resume the program execution
///
public void Release()
{
ResultEvent.Set();
}
}
}