开发者

Generate thumbnails using in C#

I am generating the thumbnails of various image file, now I want to optimize it using thread or queue. so when I select a folder it generate thumb image one by one like in windows search. I am new to C#, please help 开发者_如何学Pythonme on this. Thanks, Tanmoy


You can use Task Parallel Library to achieve that. Something like:

Generate thumbnails using in C#

Also, checkout:

  • How to: Create Thumbnail Images
  • How To: Creating Thumbnail Images


I would use the BackgroundWorker class (also see this tutorial) to generate the thumbnails in the background. Something like:

BackgroundWorker imageGenerator = new BackgroundWorker()

foreach(var filename in imageFileNames)
{
    imageGenerator.DoWork += (s, a) => GenerateThumbnailMethod(filename);
}

imageGenerator.RunWorkerAsync();

This will generate the thumbnails on a separate thread. You can also get the BackgroundWorker to let you know when it's done by assigning an event handler to its RunWorkerCompleted event. You should do this, because this allows for error checking, as the RunWorkerCompletedEventArgs object has an Error property.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜