内联映像和托管API的性能 [英] Inline Images and Performance of the Managed API

查看:80
本文介绍了内联映像和托管API的性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

警告:我对C#很新。

什么是保存内嵌图像的最佳方法?是否有任何类可以根据ContentType生成文件名,因为通过API的内联没有FileName值?或者,更好的是,有没有办法在做一个FindItems w / Attachments = true时过滤掉这些特定类型的附件?
我把一个快速测试应用程序组合在一起来获取一组过滤的电子邮件。该应用程序基本上锁定了正在进行API调用的整个时间。您甚至无法移动窗口,或单击"取消"按钮。有没有办法对API调用进行后台处理,以便它们不会阻塞整个应用程序?

解决方案

这个EWS托管API的第一个版本只暴露了一个同步接口。您调用的任何方法都将阻止它执行的线程。

但是当然有异步调用API的方法。您可以使用Thread和ThreadPool类来执行此操作,也可以将委托与BeginInvoke和EndInvoke一起使用。 这篇文章展示了如何调用ExchangeService .ResolveName使用委托异步(向下滚动以查找示例)。样本可以很容易地适应任何其他方法。


Caveat: I'm fairly new to C#.

What's the best way to save Inline Images? Are there any classes which can generate a filename based on the ContentType, since Inlines through the API don't have FileName values? Or, better yet, is there a way to filter out these specific types of attachments when doing a FindItems w/Attachments = true?

I threw together a quick test application to fetch a filtered set of emails. The application essentially locks up the entire time API calls are being made. You can't even move the window around, or click a Cancel button. Is there a way to background the API calls so they don't block the entire application?

解决方案

This first version of the EWS Managed API only exposes a synchronous interface. Any method that you call will block the thread it is executed on.

But there are of course means to call the API asynchronously. You can do that using the the Thread and ThreadPool classes, or you can use delegates with BeginInvoke and EndInvoke. This post shows how to call the ExchangeService.ResolveName asynchronously using a delegate (scroll down to find the example). The sample can easily be adapted to any other method.


这篇关于内联映像和托管API的性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆