my project is a three-tier architecture project talking to the WCF service in the backend. When a backend can retrieve data from a service, it notifies the business layer using a subscription publication, which in turn notifies the GUI layer.
I added OpenFileDialog to my UI design using the Visual Studios designer. The button event handler invokes the ShowDialog message. However, as soon as I click the button, the whole user interface freezes.
Having died a little, I found that using delegates is the preferred way to solve such problems. However, with and without a delegate, the problem persists.
Currently my code is as follows:
private void bOpen_Click(object sender, EventArgs e) { Func<Image> del = delegate { OpenFileDialog d = new OpenFileDialog(); if (d.ShowDialog() == DialogResult.OK) { return Image.FromFile(d.FileName); } return null; }; Invoke(del); }
I come from the Java world, so I'm not very good at the intricacies of C # UI programming.
Anything I miss here?
source share