0

I believe I've followed most guidelines here, so hopefully this question isn't out of place. For starters, I've Googled already, but honestly have no idea what to Google in this case. It's an oddly worded question.

Basically, my dilemma is this: I'm trying to make two characters have a conversation, using Winforms and C#. It's just two static people on a UserControl that are talking back and forth, but the user can use buttons to choose what he says back to the other character. Whenever the user presses a button to say something, I want the other character to reply with a speechbubble-like tooltip.

public void button1_Click(object sender, EventArgs e)
{
    if (conversationStage == 1)
    {
        speech.createSpeech("Response to dialog 1-1.", new Point(420, 250), this, 5000);
        caseSwitch++;
        buttonSwitcher();
    }

What I would expect to do would be something like this:

public void button1_Click(object sender, EventArgs e)
{
    if (conversationStage == 1)
    {
        speech.createSpeech("Response to dialog 1-1.", new Point(420, 250), this, 5000);
        Wait(5);
        speech.createSpeech("Next speechbubble here..." <other parameters>);
        caseSwitch++;
        buttonSwitcher();
    }

Of course, that doesn't actually work. Before somebody decides to suggest that I use Thread.Sleep, I've tried it already, and since it stops all GPU updates, it means the speechbubble never renders, which is not good. I believe my only option is to use a typical Winforms timer, but I can't seem to manipulate them (I just don't know how) in a way where I can simply integrate it into this if statement here.

I'm stuck now, and I have no idea how to proceed.

annemartijn
  • 1,538
  • 1
  • 23
  • 45
  • Which version of .NET framework are you using? – Nazmul May 23 '15 at 18:17
  • I'm confused now. Should I delete this question or is it meant to stay here for future reference? As I explained already, I didn't know what to look up, which was why I couldn't find an answer. – SassMaster May 23 '15 at 20:45
  • It is fine don't worry about it. If it need to be deleted then moderator will delete it. – Nazmul May 24 '15 at 05:53

1 Answers1

0

Using .NET 4.5 you can use the new async/await framework to sleep without locking the thread.

Check this post How can I perform a short delay in C# without using sleep?

Community
  • 1
  • 1
Nazmul
  • 575
  • 3
  • 18
  • Perfect! This is exactly what I was looking for. Thank you for that, Nazmul. And to think I just spent about 4 hours trying to manipulate a Winforms timer... – SassMaster May 23 '15 at 18:44