Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

How do i start thread with option strict?

I am trying to code with "option strict" = on
this code is working with "option strict" = off

So what did i miss to make it possible for option strict?
[Image: 5XJ7c.png]

Error message:
Code
Error    1    Overload resolution failed because no accessible 'New' can be called with these arguments:
    
    'Public Sub New(start As System.Threading.ParameterizedThreadStart)': Option Strict On does not allow narrowing in implicit type conversions between method 'Private Sub mysub(ms As Integer)' and delegate 'Delegate Sub ParameterizedThreadStart(obj As Object)'.
    
    'Public Sub New(start As System.Threading.ThreadStart)': Method 'Private Sub mysub(ms As Integer)' does not have a signature compatible with delegate 'Delegate Sub ThreadStart()'.    C:\Users\***\AppData\Local\Temporary Projects\WindowsApplication1\Form1.vb    5    13    WindowsApplication1
Try this code:
Dim th as new threading.thread(new Parameterizeredthreadstart(addressof mysub))
Code
Dim th As New Threading.Thread(New Threading.ThreadStart(Sub() mysub(delay)))
th.Start()
You are parsing data to a entry thread method.

Code
Dim delay As Integer = 5000
Dim th As New Threading.Thread(DirectCast(Sub() MySub(delay), Threading.ThreadStart))
With th
    .IsBackground = True
    .Start()
End With
(Apr 29, 2012 03:12 PM)Perplexity Wrote:  
Code
Dim th As New Threading.Thread(New Threading.ThreadStart(Sub() mysub(delay)))
th.Start()

Thanks for the replies
Will be using Perplexity's code


Possibly Related Threads...
Thread / Author Replies Views Last Post
by HackersApr 29, 2024 05:37 AM 27 460 Apr 29, 2024 05:37 AM
Last Post: nucleo_type09
[.NET] by soft2050Jun 25, 2011 10:00 PM 4 88 Jun 25, 2011 10:00 PM
Last Post: soft2050
[.NET] by H3x0SJan 8, 2011 10:47 AM 8 122 Jan 8, 2011 10:47 AM
Last Post: Poppins