public virtual Task WriteAsync(char[] buffer, int index, int count) { var tuple = new Tuple<TextWriter, char[], int, int>(this, buffer, index, count); return Task.Factory.StartNew(state => { var t = (Tuple<TextWriter, char[], int, int>)state; t.Item1.Write(t.Item2, t.Item3, t.Item4); }, tuple, CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default); }
internal static async Task CreateThumbnailAsync(StorageRepository repo, string fileName, TextWriter log) { using (var memStream = await repo.GetBlob(StorageConfig.PhotosBlobContainerName, fileName)) { MemoryStream thumbnail = null; try { thumbnail = PhotoEditor.ProcessImage(memStream); await repo.UploadBlobAsync(thumbnail, StorageConfig.ThumbnailsBlobContainerName, fileName); } catch (Exception oops) { await log.WriteAsync(oops.Message); throw oops; } finally { if (null != thumbnail) { thumbnail.Dispose(); } } } }