Results 1 to 3 of 3

Thread: Threading Basics

  1. #1

    Thread Starter
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Threading Basics

    Hi
    This code is supposed to be a threading example that writes to a console but I can make it work, can you take a lok to see what I'm doing wrong? It doesn't error, it just doesn't do anything. The code is based on an example from Francesco Balena's book.
    thanks
    VB Code:
    1. Imports System.IO
    2. Imports System.Threading
    3.     Sub DoTheTask()
    4.         For i As Integer = 1 To 10
    5.             Console.WriteLine("Msg #{0} from the second thread", i)
    6.             Thread.Sleep(200)
    7.         Next
    8.     End Sub
    9.  
    10.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    11.         Dim t As New Thread(New ThreadStart(AddressOf DoTheTask))
    12.         t.Start()
    13.         For i As Integer = 1 To 10
    14.             Console.WriteLine("Msg #{0} from the main thread", i)
    15.             Thread.Sleep(200)
    16.         Next
    17.     End Sub
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  2. #2
    Hyperactive Member
    Join Date
    Dec 2002
    Posts
    382

    Re: Threading Basics

    Code works fine for me....

    Look at your Output Tab for the results, works fine..

  3. #3

    Thread Starter
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Re: Threading Basics

    thanks,
    so the Console is not the command line console, it's the output Window?
    kevin
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width