Exemple #1
0
    public void Start()
    {
        var context = new WorkerContext(WorkThreadProc, _interval);

        if (Interlocked.CompareExchange <WorkerContext>(ref _workerContext, context, null) == null)
        {
            context.Run();
        }
        else
        {
            context.ExitEvent.Close();
            throw new InvalidOperationException("Working alredy.");
        }
    }