Click here to Skip to main content
15,921,837 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
Questioncalculate average inside my ssrs 2008 Pin
menacy22-Nov-12 10:09
menacy22-Nov-12 10:09 
AnswerRe: calculate average inside my ssrs 2008 Pin
Richard MacCutchan22-Nov-12 23:35
mveRichard MacCutchan22-Nov-12 23:35 
QuestionString compression Pin
Blikkies19-Nov-12 21:03
professionalBlikkies19-Nov-12 21:03 
AnswerRe: String compression Pin
n.podbielski19-Nov-12 21:15
n.podbielski19-Nov-12 21:15 
GeneralRe: String compression Pin
Blikkies19-Nov-12 21:19
professionalBlikkies19-Nov-12 21:19 
JokeRe: String compression Pin
n.podbielski19-Nov-12 21:22
n.podbielski19-Nov-12 21:22 
Questionestoy tratando de compilar un archivo.mex a .net Pin
yeyomax19-Nov-12 9:33
yeyomax19-Nov-12 9:33 
AnswerRe: estoy tratando de compilar un archivo.mex a .net Pin
Eddy Vluggen19-Nov-12 11:09
professionalEddy Vluggen19-Nov-12 11:09 
GeneralRe: estoy tratando de compilar un archivo.mex a .net Pin
IdeasPravinh23-Nov-12 23:47
IdeasPravinh23-Nov-12 23:47 
AnswerRe: estoy tratando de compilar un archivo.mex a .net Pin
Bernhard Hiller19-Nov-12 22:35
Bernhard Hiller19-Nov-12 22:35 
GeneralRe: estoy tratando de compilar un archivo.mex a .net Pin
yeyomax20-Nov-12 5:25
yeyomax20-Nov-12 5:25 
GeneralRe: estoy tratando de compilar un archivo.mex a .net Pin
Dave Kreskowiak20-Nov-12 6:11
mveDave Kreskowiak20-Nov-12 6:11 
Question[VB.NET 2008] Change form from separate thread (Windows CE) Pin
steve_949661319-Nov-12 2:51
professionalsteve_949661319-Nov-12 2:51 
AnswerRe: [VB.NET 2008] Change form from separate thread (Windows CE) Pin
Simon_Whale19-Nov-12 3:04
Simon_Whale19-Nov-12 3:04 
GeneralRe: [VB.NET 2008] Change form from separate thread (Windows CE) Pin
steve_949661319-Nov-12 4:37
professionalsteve_949661319-Nov-12 4:37 
AnswerRe: [VB.NET 2008] Change form from separate thread (Windows CE) Pin
Eddy Vluggen19-Nov-12 5:04
professionalEddy Vluggen19-Nov-12 5:04 
GeneralRe: [VB.NET 2008] Change form from separate thread (Windows CE) Pin
steve_949661319-Nov-12 22:54
professionalsteve_949661319-Nov-12 22:54 
GeneralRe: [VB.NET 2008] Change form from separate thread (Windows CE) Pin
Eddy Vluggen20-Nov-12 0:53
professionalEddy Vluggen20-Nov-12 0:53 
GeneralRe: [VB.NET 2008] Change form from separate thread (Windows CE) Pin
steve_949661320-Nov-12 3:36
professionalsteve_949661320-Nov-12 3:36 
GeneralRe: [VB.NET 2008] Change form from separate thread (Windows CE) Pin
Eddy Vluggen20-Nov-12 4:33
professionalEddy Vluggen20-Nov-12 4:33 
GeneralRe: [VB.NET 2008] Change form from separate thread (Windows CE) Pin
steve_949661320-Nov-12 5:23
professionalsteve_949661320-Nov-12 5:23 
GeneralRe: [VB.NET 2008] Change form from separate thread (Windows CE) Pin
Eddy Vluggen20-Nov-12 9:21
professionalEddy Vluggen20-Nov-12 9:21 
steve_9496613 wrote:
About passing a parameter in an object when I start the thread, I can't do this because in the Compact Framework (not the full .NET) only the method Thread.Start() is supported, the method Thread.Start(Object) is not supported.

Aw, darn. Without that, it's not possible to pass the form as an argument.

Since AggiornaLabel is a method of the form (as should be), you'd need to have a reference to the form in order to invoke it. An ugly bypass would be to use a "shared" member, aka a static method. Works similar to the shared integer called 'iii'.
VB
Imports System.Threading

Public Class Form1
    Dim MyNewThread As Thread

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click        
        'create the thread 
        MyNewThread = New Thread(AddressOf MyThread.MyThreadExecute)
        MyNewThread.Name = "NuovoThread"
        MyThread.ThatForm = Me
        'start the thread
        MyNewThread.Start()
    End Sub

    Public Sub AggiornaLabel(ByVal What As String)
        If InvokeRequired Then
            Invoke(New Action(Of String)(AddressOf AggiornaLabel), New Object() {What})
            Return
        End If

        Label1.Text = What
    End Sub
End Class

Public Class MyThread
    Private Shared miii As Int32 = 0
    Public Shared ThatForm As Form1

    Public Shared Property iii() As Int32
        Get
            Return miii
        End Get
        Set(ByVal value As Int32)
            miii = value
        End Set
    End Property

    Public Shared Sub MyThreadExecute()
        Do
            iii = iii + 1
            ThatForm.AggiornaLabel(iii.ToString)
            Thread.Sleep(100)
        Loop
    End Sub
End Class
That's abusing things a bit; a class that's never instantiated would be a module, eliminating the need to declare each member being 'shared';
VB
Module MyThread
    Private miii As Int32 = 0
    Public ThatForm As Form1

    Public Property iii() As Int32
        Get
            Return miii
        End Get
        Set(ByVal value As Int32)
            miii = value
        End Set
    End Property

    Public Sub MyThreadExecute()
        Do
            iii = iii + 1
            ThatForm.AggiornaLabel(iii.ToString)
            Thread.Sleep(100)
        Loop
    End Sub
End Module

Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]
They hate us for our freedom![^]

GeneralRe: [VB.NET 2008] Change form from separate thread (Windows CE) Pin
steve_949661320-Nov-12 21:25
professionalsteve_949661320-Nov-12 21:25 
GeneralRe: [VB.NET 2008] Change form from separate thread (Windows CE) Pin
Eddy Vluggen21-Nov-12 5:07
professionalEddy Vluggen21-Nov-12 5:07 
QuestionBinding gridview from webservice using jquery Pin
saravanan2509218-Nov-12 20:41
saravanan2509218-Nov-12 20:41 

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.