本文整理汇总了C#中QueueItem类的典型用法代码示例。如果您正苦于以下问题:C# QueueItem类的具体用法?C# QueueItem怎么用?C# QueueItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
QueueItem类属于命名空间,在下文中一共展示了QueueItem类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: MergeQueueItem
private static QueueItem MergeQueueItem(QueueItem item1, QueueItem item2)
{
TreeNode treeNode = new TreeNode(item1.TreeNode, item2.TreeNode);
QueueItem queuItem = new QueueItem(treeNode, item1.Priority + item2.Priority);
return queuItem;
}
开发者ID:BenderRodrigez,项目名称:DCM_01,代码行数:7,代码来源:TreeBuilder.cs
示例2: GetQueue
public virtual IEnumerable<QueueItem> GetQueue()
{
var command = new JsonRequest
{
Method = "listgroups",
Params = null
};
var response = PostCommand(command.ToJson());
CheckForError(response);
var itmes = Json.Deserialize<NzbGetQueue>(response).QueueItems;
foreach (var nzbGetQueueItem in itmes)
{
var queueItem = new QueueItem();
queueItem.Id = nzbGetQueueItem.NzbId.ToString();
queueItem.Title = nzbGetQueueItem.NzbName;
queueItem.Size = nzbGetQueueItem.FileSizeMb;
queueItem.Sizeleft = nzbGetQueueItem.RemainingSizeMb;
var parsedEpisodeInfo = Parser.Parser.ParseTitle(queueItem.Title);
if (parsedEpisodeInfo == null) continue;
var remoteEpisode = _parsingService.Map(parsedEpisodeInfo, 0);
if (remoteEpisode.Series == null) continue;
queueItem.RemoteEpisode = remoteEpisode;
yield return queueItem;
}
}
开发者ID:peterlandry,项目名称:NzbDrone,代码行数:33,代码来源:NzbgetClient.cs
示例3: DispatchRecord
private void DispatchRecord(QueueItem item, Action completionTrigger) {
_log.DebugFormat("dispatching update record '{0}'", item.Record.Id);
Coroutine.Invoke(_callback, item.Record, new Result()).WhenDone(r => {
completionTrigger();
if(r.HasException) {
var e = r.Exception;
if(item.Attempt <= _maxRetry) {
_log.DebugFormat("dispatch of '{0}' failed, sleeping for {1:0.0}s before attempting re-queue", item.Record.Id, _retrySleep.TotalSeconds);
item.Attempt++;
Async.Sleep(_retrySleep).WhenDone(r2 => {
if(!_dispatchQueue.TryEnqueue(item)) {
item.Result.Throw(new InvalidOperationException(string.Format("Unable to re-queue '{0}' for retry {1}.", item.Record.Id, item.Attempt)));
return;
}
_log.DebugFormat("re-queued '{0}' for retry {1}", item.Record.Id, item.Attempt);
});
} else {
_log.DebugFormat("dispatch of '{0}' permanently failed after {1} tries", item.Record.Id, item.Attempt);
item.Result.Throw(e);
}
} else {
_log.DebugFormat("finished dispatch of update record '{0}'", item.Record.Id);
item.Result.Return();
}
});
}
开发者ID:heran,项目名称:DekiWiki,代码行数:26,代码来源:UpdateRecordDispatcher.cs
示例4: WindowKeyDown
void WindowKeyDown(object sender, KeyEventArgs args)
{
ListView lv = (ListView)args.Source;
ZoneGroup zg = (ZoneGroup)lv.DataContext;
ZonePlayer zp = zg.Coordinator;
switch (args.Key)
{
case Key.Delete:
// have to make a copy since there will be a callback
// each time the queue is modified
QueueItem[] delete = new QueueItem[lv.SelectedItems.Count];
lv.SelectedItems.CopyTo(delete, 0);
// reverse numeric sort on queue ID
Array.Sort(delete, delegate(QueueItem a, QueueItem b) { return Comparer<int>.Default.Compare(a.NumericId, b.NumericId) * -1; });
// deletes must be synchronous & in order to work properly
ThreadPool.QueueUserWorkItem(delegate
{
foreach (QueueItem qi in delete)
{
zp.AVTransport.RemoveTrackFromQueue(qi.ItemId);
}
});
args.Handled = true;
break;
}
}
开发者ID:NathanHowell,项目名称:Sonority,代码行数:30,代码来源:QueueControl.xaml.cs
示例5: CopyTo
public void CopyTo()
{
var it0 = new QueueItem {FileName = "filename", Position = 10, Line = 1};
var it1 = new QueueItem();
Assert.IsFalse(it0.Equals(it1));
it0.CopyTo(it1);
Assert.IsTrue(it0.Equals(it1));
}
开发者ID:SlavaRa,项目名称:fdplugin-previousedit,代码行数:8,代码来源:QueueTests.cs
示例6: Using
private void Using(Texture texture)
{
if (!active) throw new Exception("Call Begin first.");
if (activeTexture==null || activeTexture.Texture != texture) {
if (recycle.Count > 0) {
activeTexture=recycle.Dequeue();
activeTexture.Texture=texture;
} else
activeTexture=new QueueItem(texture);
textures.Add(activeTexture);
}
}
开发者ID:millpond,项目名称:space-station-14,代码行数:13,代码来源:SpriteBatch.cs
示例7: Main
public static void Main()
{
// Create LinkedQueue and test its methods
QueueItem<string> element = new QueueItem<string>("a");
LinkedQueue<string> queue = new LinkedQueue<string>(element);
queue.Enqueue(new QueueItem<string>("b"));
queue.Enqueue(new QueueItem<string>("c"));
queue.Enqueue(new QueueItem<string>("d"));
queue.Enqueue(new QueueItem<string>("e"));
QueueItem<string> firstElement = queue.Dequeue();
QueueItem<string> newFirstElement = queue.Peek();
int count = queue.Count();
bool hasElement = queue.Contains(new QueueItem<string>("z"));
}
开发者ID:vasilkrvasilev,项目名称:DataStructuresAlgorithms,代码行数:14,代码来源:Example.cs
示例8: addItem
public void addItem(string category, string filename, string url)
{
// Search for the specified category
QueueHead qh = getQH(category);
// If it exists...
if (qh != null)
{
// Create a new item
QueueItem qi = new QueueItem();
// Assign its data
qi.localFilename = filename;
qi.URL = url;
// Add item to the category
qh.items.Add(qi);
}
}
开发者ID:Reikooters,项目名称:LittleDownloadManager,代码行数:19,代码来源:QueueManager.cs
示例9: Dequeue
public char Dequeue()
{
if (this.last == null)
{
throw new EmptyQueueException("you are trying to access a non-existent object");
}
QueueItem i = this.last;
QueueItem j = this.last;
while (i.Next != null)
{
j = i;
i = i.Next;
}
var value = this.first.Value;
this.first = j;
j.Next = null;
return value;
}
开发者ID:AlbertMukhammadiev,项目名称:University,代码行数:20,代码来源:PriorityQueue.cs
示例10: DispatchRecord
private void DispatchRecord(QueueItem item, Action completionTrigger) {
_log.DebugFormat("dispatching update record '{0}'", item.Record.Id);
Coroutine.Invoke(_callback, item.Record, new Result()).WhenDone(r => {
completionTrigger();
if(r.HasException) {
if(item.Attempt < _maxRetry) {
item.Attempt++;
if(!_dispatchQueue.TryEnqueue(item)) {
item.Result.Throw(new InvalidOperationException(string.Format("Unable to re-queue '{0}' for retry {1}.", item.Record.Id, item.Attempt)));
return;
}
_log.DebugFormat("re-queued '{0}' for retry {1}", item.Record.Id, item.Attempt);
return;
}
item.Result.Throw(r.Exception);
} else {
_log.DebugFormat("finished dispatch of update record '{0}'", item.Record.Id);
item.Result.Return();
}
});
}
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:21,代码来源:UpdateRecordDispatcher.cs
示例11: Enqueue
public void Enqueue(char value, int priority)
{
QueueItem newItem = new QueueItem(value, priority);
if (this.last == null)
{
this.last = newItem;
this.first = newItem;
return;
}
if (this.first.Priority < priority)
{
this.first = newItem;
}
if (this.last.Priority >= priority)
{
QueueItem temp = this.last;
this.last = new QueueItem(value, priority);
this.last.Next = temp;
return;
}
QueueItem i = this.last;
while (i.Next != null)
{
if (i.Next.Priority >= priority)
{
break;
}
i = i.Next;
}
QueueItem newElement = new QueueItem(value, priority);
newElement.Next = i.Next;
i.Next = newElement;
}
开发者ID:AlbertMukhammadiev,项目名称:University,代码行数:38,代码来源:PriorityQueue.cs
示例12: Get
/// <summary>
/// 获取图片
/// </summary>
/// <param name="url">图片地址</param>
/// <param name="action">图片生成后的回调</param>
/// <returns>默认图片</returns>
public virtual BitmapSource Get( string url, ImageCreateCallback action )
{
QueueItem item = new QueueItem() { Action = action, Url = url };
BackgroundWorker worker = null;
lock ( _waitingQueue ) {
_waitingQueue.Enqueue( item );
if ( !_isThreadActivated ) {
_isThreadActivated = true;
worker = new BackgroundWorker();
}
}
if ( worker != null ) {
worker.DoWork += ( ( send, ev ) => StartThread() );
worker.RunWorkerCompleted += ( ( s, e ) => {
lock ( _waitingQueue ) {
_isThreadActivated = false;
}
} );
worker.RunWorkerAsync();
}
return BitmapCache.DEFAULT_IMAGE;
}
开发者ID:arakuma,项目名称:wp_imagetool,代码行数:29,代码来源:ImageLoader.cs
示例13: AddToQueue
public Task AddToQueue(QueueItem item) {
return _hubContext.Clients.All.Added(item);
}
开发者ID:MaHuJa,项目名称:withSIX.Desktop,代码行数:3,代码来源:QueueHubMessenger.cs
示例14: SendResponseAsync
/// <summary>
/// Starts sending response.
/// </summary>
/// <param name="response">IMAP response.</param>
/// <param name="completedAsyncCallback">Callback to be called when this method completes asynchronously.</param>
/// <returns>Returns true is method completed asynchronously(the completedAsyncCallback is raised upon completion of the operation).
/// Returns false if operation completed synchronously.</returns>
/// <exception cref="ArgumentNullException">Is raised when <b>response</b> is null reference.</exception>
public bool SendResponseAsync(IMAP_r response,EventHandler<EventArgs<Exception>> completedAsyncCallback)
{
if(response == null){
throw new ArgumentNullException("response");
}
lock(m_pLock){
QueueItem responseItem = new QueueItem(response,completedAsyncCallback);
m_pResponses.Enqueue(responseItem);
// Start sending response, no active response sending.
if(!m_IsSending){
SendResponsesAsync();
}
// Response sent synchronously.
if(responseItem.IsSent){
return false;
}
// Response queued or sending is in progress.
else{
responseItem.IsAsync = true;
return true;
}
}
}
开发者ID:MichaelChansn,项目名称:Lumisoft.Net,代码行数:35,代码来源:IMAP_Session.cs
示例15: AddToQueue
/// <summary>
/// Adds the contol to animation queue.
/// </summary>
/// <param name="control">Target control</param>
/// <param name="mode">Animation mode</param>
/// <param name="parallel">Allows to animate it same time as other animations</param>
/// <param name="animation">Personal animation</param>
public void AddToQueue(Control control, AnimateMode mode, bool parallel = true, Animation animation = null, Rectangle clipRectangle = default(Rectangle))
{
if(animation == null)
animation = DefaultAnimation;
if (control is IFakeControl)
{
control.Visible = false;
return;
}
var item = new QueueItem() { animation = animation, control = control, IsActive = parallel, mode = mode, clipRectangle = clipRectangle };
//check visible state
switch (mode)
{
case AnimateMode.Show:
if (control.Visible)//already showed
{
OnCompleted(new QueueItem {control = control, mode = mode});
return;
}
break;
case AnimateMode.Hide:
if (!control.Visible)//already hidden
{
OnCompleted(new QueueItem { control = control, mode = mode });
return;
}
break;
}
//add to queue
lock (queue)
queue.Add(item);
lock (requests)
requests.Add(item);
}
开发者ID:modulexcite,项目名称:Animator,代码行数:45,代码来源:Animator.cs
示例16: OnCompleted
void OnCompleted(QueueItem item)
{
if (item.controller != null)
{
item.controller.Dispose();
}
lock (queue)
queue.Remove(item);
OnAnimationCompleted(new AnimationCompletedEventArg { Animation = item.animation, Control = item.control, Mode = item.mode });
}
开发者ID:modulexcite,项目名称:Animator,代码行数:11,代码来源:Animator.cs
示例17: DoAnimation
private void DoAnimation(QueueItem item)
{
if(Monitor.TryEnter(item))
try
{
if (item.controller == null)
{
item.controller = CreateDoubleBitmap(item.control, item.mode, item.animation,
item.clipRectangle);
}
if (item.controller.IsCompleted)
return;
item.controller.BuildNextFrame();
}
catch
{
OnCompleted(item);
}
}
开发者ID:modulexcite,项目名称:Animator,代码行数:19,代码来源:Animator.cs
示例18: LockAsync
/// <summary>
/// Returns a lock right away or waits asynchronously until a lock is available.
/// </summary>
/// <returns>Task indicating the task of acquiring the lock.</returns>
public Task LockAsync(string operationName)
{
if (_lockFileWatcher == null)
{
throw new InvalidOperationException(Resources.Error_AsyncLockNotInitialized);
}
// See if we can get the lock -- if not then enqueue lock request.
if (Lock(operationName))
{
return Task.FromResult(true);
}
QueueItem item = new QueueItem(operationName);
_lockRequestQueue.Enqueue(item);
return item.HasLock.Task;
}
开发者ID:projectkudu,项目名称:kudu,代码行数:21,代码来源:LockFile.cs
示例19: Request
/// <summary>
/// get web content
/// </summary>
/// <param name="url">requested url</param>
/// <param name="action">callback when finished</param>
public void Request(string url, HttpMethod method, List<KeyValuePair<string, string>> httpPostData, RequestFinished action)
{
QueueItem item = new QueueItem() { Action = action, Url = url, Method = method, PostData = httpPostData };
AddQueueItem(item);
}
开发者ID:nkwsqyyzx,项目名称:BetStrategy,代码行数:10,代码来源:TaskPool.cs
示例20: GetTask
/// <summary>
/// Get a task from a queued item
/// </summary>
/// <param name="item">queue request item</param>
/// <returns>task</returns>
private HttpTask GetTask(QueueItem item)
{
HttpTask httpTask = null;
if (item.Method == HttpMethod.Get)
{
httpTask = new GetTextHttpTask(item.Url);
}
else
{
httpTask = new PostTextHttpTask(item.Url, item.PostData);
}
httpTask.HttpRequestCompleted += (state, stream, error) =>
{
lock (_lock)
{
_tasks.Remove(httpTask);
}
if (_taskCount == 0)
{
_resetEvent.Set();
}
Interlocked.Increment(ref _taskCount);
item.Action(state, stream, error);
};
return httpTask;
}
开发者ID:nkwsqyyzx,项目名称:BetStrategy,代码行数:35,代码来源:TaskPool.cs
注:本文中的QueueItem类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论