//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System;
using System.Threading;
namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
{
///
/// Class that stores the state of a binding queue request item
///
public class QueueItem
{
///
/// QueueItem constructor
///
public QueueItem()
{
this.ItemProcessed = new ManualResetEvent(initialState: false);
}
///
/// Gets or sets the queue item key
///
public string Key { get; set; }
///
/// Gets or sets the bind operation callback method
///
public Func BindOperation { get; set; }
///
/// Gets or sets the timeout operation to call if the bind operation doesn't finish within timeout period
///
public Func? TimeoutOperation { get; set; }
///
/// Gets or sets the operation to call if the bind operation encounters an unexpected exception.
/// Supports returning an object in case of the exception occurring since in some cases we need to be
/// tolerant of error cases and still return some value
///
public Func ErrorHandler { get; set; }
///
/// Gets or sets an event to signal when this queue item has been processed
///
public virtual ManualResetEvent ItemProcessed { get; set; }
///
/// Gets or sets the result of the queued task
///
public object Result { get; set; }
///
/// Gets or sets the binding operation timeout in milliseconds
///
public int? BindingTimeout { get; set; }
///
/// Gets or sets the timeout for how long to wait for the binding lock
///
public int? WaitForLockTimeout { get; set; }
///
/// Converts the result of the execution to type T
///
public T? GetResultAsT() where T : class
{
//var task = this.ResultsTask;
return (this.Result != null)
? this.Result as T
: null;
}
}
}