Permalink
Browse files

Fix http://community.sharpdevelop.net/forums/t/11954.aspx - Cannot se…

…lect project resource as form icon: "This operation can be called on the main thread only"
  • Loading branch information...
1 parent 1876bf4 commit eedd9ddba73134f69a9ad4c0382d168bfd7f4dc2 @dgrunwald dgrunwald committed Sep 28, 2010
@@ -17,6 +17,7 @@
using ICSharpCode.FormsDesigner.Services;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
+using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.FormsDesigner.Gui
@@ -369,11 +370,15 @@ static TreeNode GetOrCreateDirectoryNode(TreeNode root, string directory)
Dictionary<string, object> GetResources(string fileName)
{
- Stream s;
- OpenedFile file = FileService.GetOpenedFile(fileName);
- if (file != null) {
- s = file.OpenRead();
- } else {
+ Stream s = null;
+ WorkbenchSingleton.SafeThreadCall(
+ delegate {
+ OpenedFile file = FileService.GetOpenedFile(fileName);
+ if (file != null) {
+ s = file.OpenRead();
+ }
+ });
+ if (s == null) {
s = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
}
using(s) {

0 comments on commit eedd9dd

Please sign in to comment.