Quote Originally Posted by Niya View Post
This is indeed getting interesting. Try what Shaggy suggested and let us know the outcome. I'm really stumped on this one, like seriously.
Code:
Public Sub noexcel(ByVal column As Integer)

        Debug.Print("before visible " & column.ToString)

        If teststring = "0" Then
            Debug.Print("thread changed site1:" & column)
            teststring = column.ToString
        End If

  

        Dim y As Long
        For y = 1 To 100
            Debug.Print("threadloop loop: " & y & "thread number:" & column)
            System.Threading.Thread.Sleep(100)
        Next


    End Sub

Global variable - excel = works as expected (thread 1 starts and ends 2 seconds before thread 2 because of the sleep between starting threads)
excel - global variable = works as expected (thread 1 starts and ends 2 seconds before thread 2 because of the sleep between starting threads)




excel + global variable = works but not as expected(including the UI thread) stop at making excel visible and opening the workbook. It appears that they are simultaneously making excel visible and simltaneously opening the workbook and simultaneously filling in the columns of data.

(all threads start looping and end looping at basically the same time)