Replacing OpenFileDialog / SaveFileDialog in .net

寵の児 提交于 2019-12-11 07:49:36

问题


In the application I'm working on, I've been trying to use the SaveFileDialog and OpenFileDialog for their customary purpose (saving and opening files.)

However, the application can't support modal forms/dialogs without crashing because too many time-sensitive things happen on the thread that owns the UI.

Rewriting the application to move those features off the UI-owning thread is not practical in the immediate term. To finish the feature I've been working on, I need a substitute for the two file dialogs, preferably a control that can live on a non-modal form.

Is there anything out there I can use that won't block my UI-owning thread?


回答1:


The only existing option I know of is Dialog Workshop.NET, a commercial product. They have a set of dialogs that have the option of being modeless (or embedded directly into a windows form instead of a separate window).

However, I'd really think about trying to move your time sensitive logic into a separate thread, instead. Having a modeless dialog will potentially confuse users, since it will not behave the way a file dialog is supposed to behave. There are also other potential consequences to having a non-blockable UI.




回答2:


too many time-sensitive things happen on the thread that owns the UI.

That is your real problem. .Net has very robust multi-threading support. I suggest you move these things elsewhere, unpleasant though it seems. It's probably less work than re-implementing the Open/Save dialogs and definitely will be less for your app in the long run.



来源:https://stackoverflow.com/questions/825552/replacing-openfiledialog-savefiledialog-in-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!