Click here to Skip to main content
15,909,898 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: VB6 Button Color Pin
Doctor Nick12-Feb-10 4:17
Doctor Nick12-Feb-10 4:17 
AnswerRe: VB6 Button Color Pin
Dave Kreskowiak12-Feb-10 2:44
mveDave Kreskowiak12-Feb-10 2:44 
QuestionDifferent ADO.net Db Update Methods-What is better? Pin
gengel11-Feb-10 22:59
gengel11-Feb-10 22:59 
AnswerRe: Different ADO.net Db Update Methods-What is better? Pin
Wayne Gaylard12-Feb-10 0:24
professionalWayne Gaylard12-Feb-10 0:24 
QuestionJoin access table to sql server Pin
C#Coudou11-Feb-10 15:28
C#Coudou11-Feb-10 15:28 
AnswerRe: Join access table to sql server Pin
Mycroft Holmes11-Feb-10 15:55
professionalMycroft Holmes11-Feb-10 15:55 
GeneralRe: Join access table to sql server Pin
C#Coudou11-Feb-10 17:38
C#Coudou11-Feb-10 17:38 
QuestionHow do I call a method from a worker thread on the master thread? Pin
BlackCatDeveloper11-Feb-10 12:04
BlackCatDeveloper11-Feb-10 12:04 
I have a report project where a timer is polling the DB for a user abort. Once the abort is discovered I want to call a procedure on the master thread interrupting it so that it can abort the report. This way I don't have to get checking for an abort in the master thread.

I tried using delegates and the invoke method hoping that it would work like the form.invoke which calls the procedure in the form's thread. But it didn't work. Anyone know how to do this without using forms?

Here is a simple example:

Delegate Sub AbortDelegate()

Public Class ReportProcesser

    Private _reportThreadID As Integer

    Friend Abort As New AbortDelegate(AddressOf AbortReport)
    Public WithEvents CheckForAbortTimer As New Timers.Timer(500)
    Public ReadOnly Property ManagedThreadID() As Integer
        Get
            Return _reportThreadID
        End Get
    End Property

    Public Sub New()
        _reportThreadID = Threading.Thread.CurrentThread.ManagedThreadId
    End Sub

    Public Sub AbortReport()

        MsgBox("Report Thread ID: " & Me.ManagedThreadID & vbCrLf & _
                "Abort Report On Thread ID: " & Threading.Thread.CurrentThread.ManagedThreadId & vbCrLf)

    End Sub

    Private Sub CheckForAbortTimer_Elapsed() Handles CheckForAbortTimer.Elapsed
        Static alreadyProcessing As Boolean = False

        If Not alreadyProcessing Then
            alreadyProcessing = True

            Me.Abort.Invoke()

            alreadyProcessing = False
        End If
    End Sub

End Class

Module Main
    Sub main()

        Dim report As New ReportProcesser
        report.CheckForAbortTimer.Start()

        Dim startTime As Date = Now
        Do Until DateDiff(DateInterval.Minute, startTime, Now) >= 5
            'end in 5 min or when stopped from Visual studio
        Loop

    End Sub
End Module


Thanks.
QuestionApplication or setup Pin
Gagan.2011-Feb-10 3:00
Gagan.2011-Feb-10 3:00 
AnswerRe: Application or setup Pin
Dave Kreskowiak11-Feb-10 4:30
mveDave Kreskowiak11-Feb-10 4:30 
GeneralRe: Application or setup Pin
Gagan.2011-Feb-10 4:34
Gagan.2011-Feb-10 4:34 
GeneralRe: Application or setup Pin
The Man from U.N.C.L.E.11-Feb-10 13:15
The Man from U.N.C.L.E.11-Feb-10 13:15 
Questionvb.net 2008 Express to SQL - Dataset does not show changes in DB Pin
gengel10-Feb-10 22:18
gengel10-Feb-10 22:18 
AnswerRe: vb.net 2008 Express to SQL - Dataset does not show changes in DB Pin
Dave Kreskowiak11-Feb-10 1:42
mveDave Kreskowiak11-Feb-10 1:42 
GeneralRe: vb.net 2008 Express to SQL - Dataset does not show changes in DB Pin
gengel11-Feb-10 2:12
gengel11-Feb-10 2:12 
GeneralRe: vb.net 2008 Express to SQL - Dataset does not show changes in DB Pin
Dave Kreskowiak11-Feb-10 3:56
mveDave Kreskowiak11-Feb-10 3:56 
GeneralRe: vb.net 2008 Express to SQL - Dataset does not show changes in DB Pin
gengel11-Feb-10 4:12
gengel11-Feb-10 4:12 
GeneralRe: vb.net 2008 Express to SQL - Dataset does not show changes in DB Pin
Dave Kreskowiak11-Feb-10 5:02
mveDave Kreskowiak11-Feb-10 5:02 
GeneralRe: vb.net 2008 Express to SQL - Dataset does not show changes in DB Pin
William Winner11-Feb-10 6:34
William Winner11-Feb-10 6:34 
AnswerRe: vb.net 2008 Express to SQL - Dataset does not show changes in DB Pin
William Winner11-Feb-10 6:16
William Winner11-Feb-10 6:16 
AnswerRe: vb.net 2008 Express to SQL - Dataset does not show changes in DB Pin
William Winner11-Feb-10 6:21
William Winner11-Feb-10 6:21 
GeneralRe: vb.net 2008 Express to SQL - Dataset does not show changes in DB Pin
gengel11-Feb-10 18:28
gengel11-Feb-10 18:28 
GeneralRe: vb.net 2008 Express to SQL - Dataset does not show changes in DB Pin
gengel11-Feb-10 18:30
gengel11-Feb-10 18:30 
GeneralRe: vb.net 2008 Express to SQL - Dataset does not show changes in DB Pin
gengel11-Feb-10 23:35
gengel11-Feb-10 23:35 
GeneralRe: vb.net 2008 Express to SQL - Dataset does not show changes in DB Pin
William Winner12-Feb-10 6:09
William Winner12-Feb-10 6:09 

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.