Click here to Skip to main content
15,895,792 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Disable/enable ctrl+alt+del buttons and autorun. Pin
Chris Quinn5-Sep-13 21:20
Chris Quinn5-Sep-13 21:20 
AnswerRe: Disable/enable ctrl+alt+del buttons and autorun. Pin
Eddy Vluggen6-Sep-13 9:26
professionalEddy Vluggen6-Sep-13 9:26 
QuestionDatabase connection using adodc control/autorun Pin
Otekpo Emmanuel5-Sep-13 13:57
Otekpo Emmanuel5-Sep-13 13:57 
AnswerRe: Database connection using adodc control/autorun Pin
Mycroft Holmes5-Sep-13 20:22
professionalMycroft Holmes5-Sep-13 20:22 
QuestionSound doesn't play instantly...but wait for next operation to complete!! Pin
Jayme653-Sep-13 3:17
Jayme653-Sep-13 3:17 
AnswerRe: Sound doesn't play instantly...but wait for next operation to complete!! Pin
Richard Deeming3-Sep-13 3:53
mveRichard Deeming3-Sep-13 3:53 
AnswerRe: Sound doesn't play instantly...but wait for next operation to complete!! Pin
Bernhard Hiller3-Sep-13 23:08
Bernhard Hiller3-Sep-13 23:08 
GeneralRe: Sound doesn't play instantly...but wait for next operation to complete!! Pin
Jayme655-Sep-13 21:23
Jayme655-Sep-13 21:23 
It doesn't work better.
Well, I had posted a simple code, hoping that it would be more clear for users to help me...but I'm afraid that I'd better post something very similar to my actual code..if I want the problem to be clearly exposed...and help you to try to help me Wink | ;-)

There's a sound class, called UISound:

VB
Imports System.Threading
Public Class UISound
    Dim writingPath As String = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) & "\_UI Sounds\"
    Public Shared WithEvents uiPlayer As New WMPLib.WindowsMediaPlayer
    Public Shared uiThread As Thread = New Thread(AddressOf ReceiveSound)
    Public Shared Sub ReceiveSound(ByVal url As String)
        uiThread = New Thread(AddressOf PlayFile)
        uiThread.Start(url)
    End Sub
    Public Shared Sub PlayFile(ByVal url As String)
        uiPlayer.URL = writingPath & url
        uiPlayer.controls.play()
    End Sub
End Class


The sound is called from a sub in the MainWindow...which itself fires other subs in cascade that involve a heavy compute time:

VB
Sub one()
    UISound.ReceiveSound("sound1.wav")
    Dim a As Integer = 0
    For i As Integer = 0 To 999999999
        a = i
    Next
    Two()
End Sub
Sub two()
    Dim a As Integer = 0
    For i As Integer = 0 To 999999999
        a = i
    Next
    Three()
End Sub
Sub Three()
    Dim a As Integer = 0
    For i As Integer = 0 To 999999999
        a = i
    Next
End Sub


It appears that the sound is played after the whole "cascade" is runned, so after Sub Three() End.


If you try this code you will verify that inserting
VB
System.Windows.Forms.Application.DoEvents()

after uiPlayer.controls.play()...doesn't work better

Thanks for your help!!
QuestionLate Binding issue in Copy Objects of AutoCAD Pin
Adnan Siddiqi1-Sep-13 9:42
Adnan Siddiqi1-Sep-13 9:42 
AnswerRe: Late Binding issue in Copy Objects of AutoCAD Pin
Richard MacCutchan1-Sep-13 20:47
mveRichard MacCutchan1-Sep-13 20:47 
GeneralRe: Late Binding issue in Copy Objects of AutoCAD Pin
Adnan Siddiqi3-Sep-13 3:18
Adnan Siddiqi3-Sep-13 3:18 
QuestionUsing Directory.GetFiles() WITH multiple extensions AND sort order Pin
Jayme651-Sep-13 0:15
Jayme651-Sep-13 0:15 
AnswerRe: Using Directory.GetFiles() WITH multiple extensions AND sort order Pin
Eddy Vluggen1-Sep-13 1:59
professionalEddy Vluggen1-Sep-13 1:59 
AnswerRe: Using Directory.GetFiles() WITH multiple extensions AND sort order Pin
Eddy Vluggen2-Sep-13 3:16
professionalEddy Vluggen2-Sep-13 3:16 
QuestionHow to Run charmap.exe with a chosen font? Pin
Alan Burkhart31-Aug-13 1:41
Alan Burkhart31-Aug-13 1:41 
AnswerRe: How to Run charmap.exe with a chosen font? Pin
Dave Kreskowiak31-Aug-13 3:13
mveDave Kreskowiak31-Aug-13 3:13 
GeneralRe: How to Run charmap.exe with a chosen font? Pin
Alan Burkhart31-Aug-13 6:01
Alan Burkhart31-Aug-13 6:01 
GeneralRe: How to Run charmap.exe with a chosen font? Pin
Dave Kreskowiak31-Aug-13 8:27
mveDave Kreskowiak31-Aug-13 8:27 
AnswerRe: How to Run charmap.exe with a chosen font? Pin
TnTinMn2-Sep-13 5:52
TnTinMn2-Sep-13 5:52 
AnswerRe: How to Run charmap.exe with a chosen font? Pin
Marco Bertschi3-Sep-13 4:30
protectorMarco Bertschi3-Sep-13 4:30 
QuestionRandom Generator not Generating Pin
Zyndell29-Aug-13 9:55
Zyndell29-Aug-13 9:55 
SuggestionRe: Random Generator not Generating Pin
Richard MacCutchan29-Aug-13 21:17
mveRichard MacCutchan29-Aug-13 21:17 
AnswerRe: Random Generator not Generating Pin
Dave Kreskowiak30-Aug-13 2:52
mveDave Kreskowiak30-Aug-13 2:52 
AnswerRe: Random Generator not Generating Pin
Zyndell30-Aug-13 7:48
Zyndell30-Aug-13 7:48 
GeneralRe: Random Generator not Generating Pin
Dave Kreskowiak30-Aug-13 12:45
mveDave Kreskowiak30-Aug-13 12:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.