{
public override Task<MemoryImage> LoadThumbnailImageAsync(CancellationToken token)
{
- return Task.Factory.StartNew(() => MemoryImage.CopyFromBytes(File.ReadAllBytes("Resources/" + this.ThumbnailUrl)), token);
+ return Task.Run(() => MemoryImage.CopyFromBytes(File.ReadAllBytes("Resources/" + this.ThumbnailUrl)), token);
}
}
}
{
var cancelToken = this.cancelTokenSource.Token;
- return Task.Factory.StartNew(() =>
+ return Task.Run(() =>
{
Task<MemoryImage> cachedImageTask = null;
lock (this.lockObject)
return imageTask;
}
}
- }, cancelToken, TaskCreationOptions.None, TaskScheduler.Default).Unwrap();
+ }, cancelToken);
}
public MemoryImage TryGetFromCache(string address)
private Task GetImageAsync(bool force = false)
{
if (string.IsNullOrEmpty(this.imageUrl))
- return Task.Factory.StartNew(() => { });
+ return Task.FromResult(0);
var uiScheduler = TaskScheduler.FromCurrentSynchronizationContext();
{
public override Task<MemoryImage> LoadThumbnailImageAsync(CancellationToken token)
{
- return Task.Factory.StartNew(() =>
+ return Task.Run(() =>
{
var oauth = new HttpOAuthApiProxy();
TonTwitterCom.InitializeOAuthToken(oauth);
else
throw new WebException(statusCode.ToString(), WebExceptionStatus.ProtocolError);
}
- },
- token, TaskCreationOptions.None, TaskScheduler.Default); // 明示しないと TaskScheduler.Current になり UI スレッド上で実行されてしまう
+ }, token);
}
}
}
var statusId = long.Parse(match.Groups["StatusId"].Value);
var uiScheduler = TaskScheduler.FromCurrentSynchronizationContext();
- Task.Factory.StartNew(() =>
+ Task.Run(() =>
{
var post = this._statuses[statusId];
if (post == null)
throw new WebApiException(err);
}
return post;
- }, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default)
+ })
.ContinueWith(t =>
{
if (t.IsFaulted)
public Task OpenUriAsync(string UriString)
{
- return Task.Factory.StartNew(() =>
+ return Task.Run(() =>
{
string myPath = UriString;
var cancelToken = this.cancelTokenSource.Token;
var uiScheduler = TaskScheduler.FromCurrentSynchronizationContext();
- this.task = Task.Factory.StartNew(() => this.GetThumbailInfo(post), cancelToken, TaskCreationOptions.None, TaskScheduler.Default)
+ this.task = Task.Run(() => this.GetThumbailInfo(post), cancelToken)
.ContinueWith(t => /* await使いたい */
{
var thumbnails = t.Result;