Hi,

I created a little test program, which works like you think it should (I
executed 'vbnc test.vb && mono test.exe').

If it still doesn't work for you, can you provide a complete sample I can
just compile and try to run?

Rolf


imports system
imports system.windows.forms
imports system.threading

public class F 
        inherits system.windows.forms.form
        dim Go as boolean
        
        Private Sub KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
                Console.WriteLine ("Keypress:  {0}", e.KeyCode)
                if e.KeyCode = Keys.T then Go = True
                if e.KeyCode = Keys.S then Exec
        end sub

        sub Exec
                Console.WriteLine ("Exec")
                Go = false
                Do
                        Application.DoEvents()
                        Threading.Thread.Sleep(1)
                Loop Until Go = True
                Console.WriteLine ("Exec [Done]")
        end sub
        
        shared sub Main
                Application.Run (new F ())
        end sub
end class



>-----Original Message-----
>From: [email protected] [mailto:mono-vb-
>[email protected]] On Behalf Of Yeek
>Sent: viernes, 03 de septiembre de 2010 20:48
>To: [email protected]
>Subject: [mono-vb] Wait for key press
>
>
>Hi everyone
>
>I'm an intermediate programmer mainly working with VS 2008 using VB. I'm
>currently trying to port two of my projects to Mac OS X using Mono and
>MonoDevelop. During the ports I bumped into several issues that I was able
>to resolve. But now I'm struggling with a couple of lines that seem not to
>work with Mono (but do so with VB). What I would like to do is to continue
>code execution only after a certain key was pressed. I implemented the
>following lines in my main code:
>
>Go = false
>Do
>     Application.DoEvents()
>     Threading.Thread.Sleep(1)
>Loop Until Go = True
>
>
>And the global variable 'Go' is handled in the following sub:
>
>Private Sub KeyPress(ByVal sender As Object, ByVal e As
>System.Windows.KeyEventArgs) Handles Me.KeyUp
>     if e.KeyCode = Keys.T then Go = True
>end sub
>
>Using the lines above stops the execution of the code completely and key
>presses have no impact. Does anyone have an idea why this is the case and
>can maybe point me in the right direction on how to solve this issue?
>
>Any help is greatly appreciated. Thanks in advance!
>Martin
>
>
>
>--
>View this message in context: http://mono.1490590.n4.nabble.com/Wait-for-
>key-press-tp2526099p2526099.html
>Sent from the Mono - VB mailing list archive at Nabble.com.
>_______________________________________________
>Mono-vb mailing list
>[email protected]
>http://lists.ximian.com/mailman/listinfo/mono-vb

_______________________________________________
Mono-vb mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/mono-vb

Reply via email to