本文整理汇总了C#中WaitCallback类的典型用法代码示例。如果您正苦于以下问题:C# WaitCallback类的具体用法?C# WaitCallback怎么用?C# WaitCallback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WaitCallback类属于命名空间,在下文中一共展示了WaitCallback类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WebcamVisionThreadGrabFrameMulti
/// <summary>
/// constructor
/// </summary>
public WebcamVisionThreadGrabFrameMulti(WaitCallback callback, object data, bool loop)
{
if (callback == null) throw new ArgumentNullException("callback");
_callback = callback;
_data = data;
_loop = loop;
}
示例2: AsyncResult
internal AsyncResult (WaitCallback cb, object state, bool capture_context)
{
async_state = state;
async_delegate = cb;
if (capture_context)
current = ExecutionContext.Capture ();
}
示例3: Execute
// Main executing of commands
internal string Execute(string clientId, string sessionId, string commands, string callback)
{
Log(clientId, sessionId, commands);
string newSessionId = TTE.NewSessionId();
try {
string cleanCommands = _statementProcessor.Clean(commands);
string[] splitCommands = _statementProcessor.Split(cleanCommands, false);
ArrayList instantiatedCommands = _statementProcessor.Instantiate(splitCommands, clientId, newSessionId, callback);
foreach (CommandContainer command in instantiatedCommands) {
command.OrigSessionId = sessionId;
_commandProcessor.Create(command);
}
// The callback value should be a http, https or tcp connection string, this will be called when the process has stopped running
if (callback != "") {
WaitCallback wc = new WaitCallback(ProcessCommand);
ThreadPool.QueueUserWorkItem(wc, newSessionId);
} else {
ProcessCommand(newSessionId);
}
} catch (Exception ex) {
Log(ex); _messageProcessor.Create(clientId, newSessionId, Config.ClientId, enmMessageCategory.Exception, ex.Message);
}
return newSessionId;
}
示例4: ServiceJob
/// <summary>
/// Timer initialization
/// </summary>
/// <param name="workFunction">Job working function</param>
/// <param name="workingPoints">Working time points</param>
public ServiceJob(WaitCallback workFunction, IList<DateTime> workingPoints)
{
if (workingPoints == null) throw new ArgumentNullException("workingPoints");
Execute = workFunction;
WorkingPoints = workingPoints;
}
示例5: Open
public void Open()
{
if (listenSockets == null)
{
listenSockets = new List<Socket>();
if (!ipAddress.Equals(IPAddress.Broadcast))
{
listenSockets.Add(CreateListenSocket(this.ipAddress, this.port, multicast));
}
else
{
listenSockets.Add(CreateListenSocket(IPAddress.Any, this.port, multicast));
if (Socket.OSSupportsIPv6)
{
listenSockets.Add(CreateListenSocket(IPAddress.IPv6Any, this.port, multicast));
}
}
}
this.onReceive = new AsyncCallback(this.OnReceive);
WaitCallback startReceivingCallback = new WaitCallback(StartReceiving);
Socket[] socketsSnapshot = listenSockets.ToArray();
for (int i = 0; i < socketsSnapshot.Length; i++)
{
ThreadPool.QueueUserWorkItem(startReceivingCallback, socketsSnapshot[i]);
}
}
示例6: RequestQueue
// ctor
internal RequestQueue(int minExternFreeThreads, int minLocalFreeThreads, int queueLimit) {
_minExternFreeThreads = minExternFreeThreads;
_minLocalFreeThreads = minLocalFreeThreads;
_queueLimit = queueLimit;
_workItemCallback = new WaitCallback(this.WorkItemCallback);
}
示例7: WorkItem
public WorkItem(WorkItemId taskID, WaitCallback wc, IAsyncResult state, ExecutionContext ctx)
{
_callback = wc;
_state = state;
_ctx = ctx;
_taskID = taskID;
}
示例8: AsyncProcessMessage
public virtual IMessageCtrl AsyncProcessMessage(IMessage reqMsg, IMessageSink replySink)
{
ADAsyncWorkItem item = new ADAsyncWorkItem(reqMsg, this, replySink);
WaitCallback callBack = new WaitCallback(item.FinishAsyncWork);
ThreadPool.QueueUserWorkItem(callBack);
return null;
}
示例9: BeginExecute
public override object BeginExecute(WaitCallback waitCallback, object state)
{
Thread result = new Thread(new ParameterizedThreadStart(waitCallback));
result.IsBackground = true;
result.Start(state);
return result;
}
示例10: QueueItemWrapper
// this function adds an item to the queue, and takes care of updating the counters.
// All functions added to the queue should be wrapped in this wrapper.
public void QueueItemWrapper(WaitCallback workFunction, object parametersIn)
{
lock (counterLock)
{
queueLength--;
analysisThreadCount++;
}
try
{
workFunction(parametersIn);
}
catch (Exception e)
{
// if there's an exception thrown while adding a block then we're
// pretty much stuck. The best we can do is log it and eat it to
// stop it killing the rest of the program.
controller.log("Exception thrown analysing " + parametersIn.ToString());
controller.errorLog("Exception thrown analysing " + parametersIn.ToString());
controller.errorLog(e.ToString());
controller.errorLog("======================");
controller.errorLog("");
return;
}
finally
{
lock (counterLock) analysisThreadCount--;
}
lock (counterLock)
{
totalAnalysed++;
currentAnalysisTotal++;
}
}
示例11: Schedule
protected internal override void Schedule (WaitCallback callback, Guid workflowInstanceId, DateTime whenUtc, Guid timerId)
{
//WorkflowInstance wi = WorkflowRuntime.GetInstanceFromGuid (workflowInstanceId);
//wi.TimerEventSubscriptionCollection.Add
// (new TimerEventSubscription (workflowInstanceId, timerId));
}
示例12: Enqueue
public static void Enqueue(WaitCallback callback, Policy policy)
{
switch(policy)
{
case Policy.Immediate:
logger.Info("Immediately running callback {0}",
callback.Method.Name);
ThreadPool.QueueUserWorkItem(new WaitCallback(callback));
break;
case Policy.Queued:
lock (queue)
{
if (cooledDown)
{
logger.Info("Immediately putting callback {0}",
callback.Method.Name);
ThreadPool.QueueUserWorkItem(
new WaitCallback(callback));
}
else
{
logger.Debug("Queuing callback {0} for later execution",
callback.Method.Name);
queue.Add(callback);
}
}
break;
}
}
示例13: ThreadServerReceive
/// <summary>
/// constructor
/// </summary>
public ThreadServerReceive(WaitCallback callback, dpslamServer server, ArrayList receive_buffer)
{
if (callback == null) throw new ArgumentNullException("callback");
_callback = callback;
_server = server;
_buffer = receive_buffer;
}
示例14: ConvertSqlServerToSQLiteDatabase
/// <summary>
/// This method takes as input the connection string to an SQL Server database
/// and creates a corresponding SQLite database file with a schema derived from
/// the SQL Server database.
/// </summary>
/// <param name="sqlServerConnString">The connection string to the SQL Server database.</param>
/// <param name="sqlitePath">The path to the SQLite database file that needs to get created.</param>
/// <param name="password">The password to use or NULL if no password should be used to encrypt the DB</param>
/// <param name="handler">A handler delegate for progress notifications.</param>
/// <param name="selectionHandler">The selection handler that allows the user to select which
/// tables to convert</param>
/// <remarks>The method continues asynchronously in the background and the caller returned
/// immediatly.</remarks>
public static void ConvertSqlServerToSQLiteDatabase(string sqlServerConnString,
string sqlitePath, string password, SqlConversionHandler handler,
SqlTableSelectionHandler selectionHandler,
FailedViewDefinitionHandler viewFailureHandler,
bool createTriggers)
{
// Clear cancelled flag
_cancelled = false;
WaitCallback wc = new WaitCallback(delegate(object state)
{
try
{
_isActive = true;
ConvertSqlServerDatabaseToSQLiteFile(sqlServerConnString, sqlitePath, password, handler, selectionHandler, viewFailureHandler, createTriggers);
_isActive = false;
handler(true, true, 100, "Finished converting database");
}
catch (Exception ex)
{
_log.Error("Failed to convert SQL Server database to SQLite database", ex);
_isActive = false;
handler(true, false, 100, ex.Message);
} // catch
});
ThreadPool.QueueUserWorkItem(wc);
}
示例15: OnBegin
//异步页面的任务启动方法
public IAsyncResult OnBegin(object sender, EventArgs e,
AsyncCallback cb, object extraData)
{
_proc = new WaitCallback(ChatInvokeProc);
Hashtable theUser = new Hashtable();
theUser = (Hashtable)extraData;
string user = theUser["guid"].ToString();
_guid = user;
Thread.CurrentThread.Name = "上下文线程" + user;
//用户处理,不存在则增加,即为登录
theUser["asyn"] = this;
theUser["lastUpdateTime"] = DateTime.Now.ToString();
Hashtable feachUser = new Hashtable();
bool isInCach=false;
for (var i = 0; i < globalCache.userCache.Count; i++)
{
feachUser = (Hashtable)globalCache.userCache[i];
if (theUser["guid"].ToString() == feachUser["guid"].ToString())
{
globalCache.userCache[i] = theUser;
isInCach = true;
}
}
if (!isInCach)
{
globalCache.userCache.Add(theUser);
}
//开始异步执行,这里会开启一个新的辅助线程
return _proc.BeginInvoke(extraData, cb, extraData);
}