本文整理汇总了C#中QueueItem类的典型用法代码示例。如果您正苦于以下问题:C# QueueItem类的具体用法?C# QueueItem怎么用?C# QueueItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
QueueItem类属于命名空间,在下文中一共展示了QueueItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
}
示例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();
}
});
}
示例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;
}
}
示例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));
}
示例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);
}
}
示例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"));
}
示例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);
}
}
示例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;
}
示例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();
}
});
}
示例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;
}
示例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;
}
示例13: AddToQueue
public Task AddToQueue(QueueItem item) {
return _hubContext.Clients.All.Added(item);
}
示例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;
}
}
}
示例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);
}