本文整理汇总了C#中ITask类的典型用法代码示例。如果您正苦于以下问题:C# ITask类的具体用法?C# ITask怎么用?C# ITask使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITask类属于命名空间,在下文中一共展示了ITask类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Add
public void Add(ITask task)
{
if (task == null)
throw new ArgumentNullException();
Add(new EnumerableTask(task));
}
示例2: TaskLoggingHelperExtension
/// <summary>
/// public constructor
/// </summary>
public TaskLoggingHelperExtension(ITask taskInstance, ResourceManager primaryResources, ResourceManager sharedResources, string helpKeywordPrefix) :
base(taskInstance)
{
this.TaskResources = primaryResources;
this.TaskSharedResources = sharedResources;
this.HelpKeywordPrefix = helpKeywordPrefix;
}
示例3: TaskViewModel
protected TaskViewModel(ILogger logger, ITask task, string name, string description, object icon)
{
if (logger == null)
throw new ArgumentNullException("logger");
if (task == null)
throw new ArgumentNullException("task");
if (name == null)
throw new ArgumentNullException("name");
if (description == null)
throw new ArgumentNullException("description");
if (icon == null)
throw new ArgumentNullException("icon");
this.logger = logger;
this.task = task;
this.name = name;
this.description = description;
this.icon = icon;
task.AddStoppedCallback(() => OnStopped());
task.AddCancelledCallback(() => OnCancelled());
task.AddCompletedCallback(() => OnCompleted());
task.AddErrorCallback(error => OnError(error));
task.AddFailedCallback(() => OnFailed());
task.AddPausedCallback(() => OnPaused());
task.AddProgressCallback(progress => OnProgressChanged(progress));
task.AddItemChangedCallback(item => OnItemChanged(item));
task.AddResumedCallback(() => OnResumed());
task.AddStartedCallback(() => OnStarted());
}
示例4: GetV1Path
internal static string GetV1Path(ITask v1Task)
{
var ppszFileName = string.Empty;
try { ((IPersistFile)v1Task).GetCurFile(out ppszFileName); }
catch (Exception ex) { throw ex; }
return ppszFileName;
}
示例5: FillTask
private void FillTask(ITask task)
{
questionSpelling.Content = task.Question.Spelling;
questionTranscription.Content = task.Question.Transcription;
answers.ItemsSource = task.Answers;
answers.ItemContainerStyleSelector = BuildStyleSelector(false);
}
示例6: ContainsTask
public bool ContainsTask(ITask task)
{
if(task.Category is DummyCategory)
return (task.Category.Name.CompareTo(name) == 0);
else
return false;
}
示例7: ContainsTask
public bool ContainsTask(ITask task)
{
if(task.Category is RtmCategory)
return ((task.Category as RtmCategory).ID.CompareTo(ID) == 0);
else
return false;
}
示例8: LogTaskState
public void LogTaskState(ITaskExecuteClient client, ITask task, TaskMessage message)
{
//��������Լ�¼��־
if (this.Storage != null)
this.Storage.SaveTaskChangedState(task, message);
}
示例9: Execute
public IResponse Execute(ITask task)
{
Debug.WriteLine(string.Format("{0}: Received task", DateTime.Now));
bool successful = true;
Exception exception = null;
IResult result = null;
try
{
ITaskExecutor taskExecutor = taskExecuterFactory.CreateExecuterFor(task);
Debug.WriteLine(string.Format("{0}: Executing {1}", DateTime.Now, task.GetType().Name));
result = taskExecutor.Execute(task);
}
catch(Exception e)
{
Debug.WriteLine(string.Format("{0}: Error in {1}, {2} ({3})", DateTime.Now, task.GetType().Name, e.GetType().Name, e.Message));
successful = false;
exception = e;
logger.LogException(LogLevel.Debug, "Exception when executing task: " + task.GetType().Name, e);
}
var resultType = task.GetType().GetInterfaces().Single(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof (ITask<>)).GetGenericArguments()[0];
return CreateResponse(resultType, result, successful, exception);
}
示例10: Execute
public TaskContext Execute(ITask task, object associatedData = null)
{
var context = new TaskContext(task, associatedData);
_dispatcher.BeginInvoke(() =>
{
_all.Add(task);
_contexts.Add(context);
UpdateBusy();
});
task.Execute(context).ContinueWith((p, d) =>
{
_dispatcher.BeginInvoke(() =>
{
_all.Remove(task);
_contexts.Remove(context);
UpdateBusy();
});
}).Failed((p, d) =>
{
});
return context;
}
示例11: Compare
/// <summary>
/// This is the same as CompareTo above but should use completion date
/// instead of due date. This is used to sort items in the
/// CompletedTaskGroup.
/// </summary>
/// <returns>
/// whether the task has lower, equal or higher sort order.
/// </returns>
public override int Compare(ITask x, ITask y)
{
bool isSameDate = true;
if (x.CompletionDate.Year != y.CompletionDate.Year
|| x.CompletionDate.DayOfYear != y.CompletionDate.DayOfYear)
isSameDate = false;
if (!isSameDate) {
if (x.CompletionDate == DateTime.MinValue) {
// No completion date set for some reason. Since we already
// tested to see if the dates were the same above, we know
// that the passed-in task has a CompletionDate set, so the
// passed-in task should be "higher" in the sort.
return 1;
} else if (y.CompletionDate == DateTime.MinValue) {
// "this" task has a completion date and should evaluate
// higher than the passed-in task which doesn't have a
// completion date.
return -1;
}
return x.CompletionDate.CompareTo (y.CompletionDate);
}
// The completion dates are the same, so no sort based on other
// things.
return CompareByPriorityAndName (x, y);
}
示例12: AssertExecutableIs
public TaskDefinitionAssertions AssertExecutableIs(ITask<object> task)
{
AssertDefined();
Assert.That(TaskWithBehaviors.Task, Is.EqualTo(task));
return this;
}
示例13: Send
public void Send(ITask task)
{
if (!this.running)
this.Start();
this.queue.Enqueue(task);
}
示例14: Process
public void Process(object o, ITask task)
{
string path = BasePath + "/" + task.Identify + "/";
try
{
string filename;
var key = o as IHasKey;
if (key != null)
{
filename = path + key.Key + ".json";
}
else
{
//check
filename = path + Encrypt.Md5Encrypt(o.ToString()) + ".json";
}
FileInfo file = GetFile(filename);
using (StreamWriter printWriter = new StreamWriter(file.OpenWrite(), Encoding.UTF8))
{
printWriter.WriteLine(JsonConvert.SerializeObject(o));
}
}
catch (Exception e)
{
_logger.Warn("write file error", e);
throw;
}
}
示例15: QueueTask
public void QueueTask(ITask task)
{
Task newTask = new Task(delegate () {
task.Execute();
});
newTask.RunSynchronously(this);
}