I did some UI work in C# lately and discovered all kind of cool new stuff. So cool, I couldn't resist sharing it with the world.
Lets say we have a multi-threaded application that throws tasks (TPL) in the back-end.
The tasks report back and we want to reflect it in the UI but we should update UI always in the main thread. We use Invokefor and in many places in the code we have chunks of the kind:
void SomeFunction()
{
if (this.InvokeRequired)
this.Invoke(new MethodInvoker(SomeFunction)
else
{
// Here goes some UI functionality
}
}
With .NET 3.0 we have Action so we can write one function like this
or even a code block like this:
Fun ...
void DoUiStuff(Action a)
{
if
(this.InvokeRequired)
this.Invoke(new MethodInvoker(a));
else
a();
}
Then whenever we want a UI action we write a lambda expression for example:
DoUiStuff(() => progressBar.Visible = true);
DoUiStuff(() => progressBar.Visible = true);
DoUiStuff(() =>
{
progressBar.Visible = false;
MessageBox.Show("Done!");
});
Hello sir,
ReplyDeletei want to read dicom(MRI)images aund use them in my project debelop in c .How can i read MRI images that are save in a folder?? Can you please help me out.
There are plenty of examples in this blog and in our examples package.
DeleteHi sir.
ReplyDeleteI want divide dicom multi frame image into dicom frmaes. is there any piece of code to do this?
thanks in advance.
thanks,
Santosh
Hi Sir,
ReplyDeleteI want to divide Dicom multi frame image into number of dicom frames. is there any way and any piece of code. please help.
thanks in advance.
hmmm ... not something ready in our examples :-(
DeleteLet mel think of something.