POSTMESSAGE Equivalent??

H

Harry Whitehouse

I have a form which, when launched, automatically begins a fairly intensive
process. The problem is that the process is so intensive that the form
doesn't have time to draw itself -- it only becomes visible at the end of
the process.

In C++ I used to solve this type of problem by sending a POSTMESSAGE during
the dialog initialization process. The POSTMESSAGE would trigger a member
which performed the intensive process. But the dialog would always have
plenty of time to render.

What I'm doing in C# is trying to emulate a button press like this, but this
is causing the form to draw at the very end of the process. What I want to
insure is that the form is completely rendered before I begin the process.

public Form1()
{

InitializeComponent();

button2_Click(new Object(),new EventArgs());

}



private void button2_Click(object sender, System.EventArgs e)

{

// CPU Intensive process

}



Any thoughts how I might do this in C#??



TIA



Harry
 
E

Eric Cadwell

Have you tried calling through a delegate? Seems to partially work with this
test.

private delegate void ButtonClick(object sender, System.EventArgs e);
private System.Windows.Forms.Button button1;
private System.ComponentModel.Container components = null;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, System.EventArgs e)
{
for(int i = 0; i < 2000; i++)
{
Text = "i = " + i.ToString();
}
}
private void Form1_Load(object sender, System.EventArgs e)
{
//button1_Click(this, null);
this.BeginInvoke(new ButtonClick(button1_Click), new object[] { this,
null });
}

HTH,
Eric Cadwell
http://www.origincontrols.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top