473,386 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

how to create Thread?

I have an mdi form and I am trying to call a procedure -
"myTest" in the parent from the childform. I am
experimenting using a thread, but the thread is not
releasing the childform. I place a breakpoint in "myTest"
on the parent form and I have a
msgbox("Done here!") on the childform. The program stops
at the breakpoint in "myTest" but does not continue to the
msgbox until after I have finished with "myTest". Here is
what I have in the childform:
----------------------------------------------
Imports System
Imports System.Threading
....
Public Class childfrm

Private Sub btn_Click(...)...
Dim p As New frmParent
Dim t As New Thread(AddressOf p.myTest())
t.Start()
MsgBox("done here!")
End Sub
End Class
------------------------------------------------
"myTest" runs OK, but not reaching msgbox in childform
until "myTest" is done first.

I also get this message in the output window after running
everything:

The thread '<No Name>' (0xb48) has exited with code 0
(0x0).

Am I using the Thread object correctly? Could someone
tell me how to use Threading correctly here?

TIA
Adda
Nov 20 '05 #1
18 1024
Hi,

Why are you creating a new frmparent. Why dont you try

Dim p as frmParent = Me.Parent

Ken
-------------------
"Adda" <an*******@discussions.microsoft.com> wrote in message
news:1a*****************************@phx.gbl...
I have an mdi form and I am trying to call a procedure -
"myTest" in the parent from the childform. I am
experimenting using a thread, but the thread is not
releasing the childform. I place a breakpoint in "myTest"
on the parent form and I have a
msgbox("Done here!") on the childform. The program stops
at the breakpoint in "myTest" but does not continue to the
msgbox until after I have finished with "myTest". Here is
what I have in the childform:
----------------------------------------------
Imports System
Imports System.Threading
...
Public Class childfrm

Private Sub btn_Click(...)...
Dim p As New frmParent
Dim t As New Thread(AddressOf p.myTest())
t.Start()
MsgBox("done here!")
End Sub
End Class
------------------------------------------------
"myTest" runs OK, but not reaching msgbox in childform
until "myTest" is done first.

I also get this message in the output window after running
everything:

The thread '<No Name>' (0xb48) has exited with code 0
(0x0).

Am I using the Thread object correctly? Could someone
tell me how to use Threading correctly here?

TIA
Adda

Nov 20 '05 #2
Hi,

Why are you creating a new frmparent. Why dont you try

Dim p as frmParent = Me.Parent

Ken
-------------------
"Adda" <an*******@discussions.microsoft.com> wrote in message
news:1a*****************************@phx.gbl...
I have an mdi form and I am trying to call a procedure -
"myTest" in the parent from the childform. I am
experimenting using a thread, but the thread is not
releasing the childform. I place a breakpoint in "myTest"
on the parent form and I have a
msgbox("Done here!") on the childform. The program stops
at the breakpoint in "myTest" but does not continue to the
msgbox until after I have finished with "myTest". Here is
what I have in the childform:
----------------------------------------------
Imports System
Imports System.Threading
...
Public Class childfrm

Private Sub btn_Click(...)...
Dim p As New frmParent
Dim t As New Thread(AddressOf p.myTest())
t.Start()
MsgBox("done here!")
End Sub
End Class
------------------------------------------------
"myTest" runs OK, but not reaching msgbox in childform
until "myTest" is done first.

I also get this message in the output window after running
everything:

The thread '<No Name>' (0xb48) has exited with code 0
(0x0).

Am I using the Thread object correctly? Could someone
tell me how to use Threading correctly here?

TIA
Adda

Nov 20 '05 #3
Hi Ken,

I actually tried something like that a few days ago but
could not get the correct syntax (still in the migration
process from vb6). So I tried it with your syntax, but I
was having an implicit conversion problem since I had
Option Strict On. So I turned it off. Now I get an error
that the specified cast is not valid. So I tried

Dim p as frmParent = CType(Me.Parent,
System.Windows.Forms.Form)

but still having problem with specified cast not valid. I
appologize for my newbieness with .Net (just know that I
hate having to go through the amateur phase all over
again :).

Adda
-----Original Message-----
Hi,

Why are you creating a new frmparent. Why dont you try
Dim p as frmParent = Me.Parent

Ken
-------------------
"Adda" <an*******@discussions.microsoft.com> wrote in messagenews:1a*****************************@phx.gbl...
I have an mdi form and I am trying to call a procedure -
"myTest" in the parent from the childform. I am
experimenting using a thread, but the thread is not
releasing the childform. I place a breakpoint in "myTest" on the parent form and I have a
msgbox("Done here!") on the childform. The program stops at the breakpoint in "myTest" but does not continue to the msgbox until after I have finished with "myTest". Here is what I have in the childform:
----------------------------------------------
Imports System
Imports System.Threading
...
Public Class childfrm

Private Sub btn_Click(...)...
Dim p As New frmParent
Dim t As New Thread(AddressOf p.myTest())
t.Start()
MsgBox("done here!")
End Sub
End Class
------------------------------------------------
"myTest" runs OK, but not reaching msgbox in childform
until "myTest" is done first.

I also get this message in the output window after running everything:

The thread '<No Name>' (0xb48) has exited with code 0
(0x0).

Am I using the Thread object correctly? Could someone
tell me how to use Threading correctly here?

TIA
Adda

.

Nov 20 '05 #4
Hi Ken,

I actually tried something like that a few days ago but
could not get the correct syntax (still in the migration
process from vb6). So I tried it with your syntax, but I
was having an implicit conversion problem since I had
Option Strict On. So I turned it off. Now I get an error
that the specified cast is not valid. So I tried

Dim p as frmParent = CType(Me.Parent,
System.Windows.Forms.Form)

but still having problem with specified cast not valid. I
appologize for my newbieness with .Net (just know that I
hate having to go through the amateur phase all over
again :).

Adda
-----Original Message-----
Hi,

Why are you creating a new frmparent. Why dont you try
Dim p as frmParent = Me.Parent

Ken
-------------------
"Adda" <an*******@discussions.microsoft.com> wrote in messagenews:1a*****************************@phx.gbl...
I have an mdi form and I am trying to call a procedure -
"myTest" in the parent from the childform. I am
experimenting using a thread, but the thread is not
releasing the childform. I place a breakpoint in "myTest" on the parent form and I have a
msgbox("Done here!") on the childform. The program stops at the breakpoint in "myTest" but does not continue to the msgbox until after I have finished with "myTest". Here is what I have in the childform:
----------------------------------------------
Imports System
Imports System.Threading
...
Public Class childfrm

Private Sub btn_Click(...)...
Dim p As New frmParent
Dim t As New Thread(AddressOf p.myTest())
t.Start()
MsgBox("done here!")
End Sub
End Class
------------------------------------------------
"myTest" runs OK, but not reaching msgbox in childform
until "myTest" is done first.

I also get this message in the output window after running everything:

The thread '<No Name>' (0xb48) has exited with code 0
(0x0).

Am I using the Thread object correctly? Could someone
tell me how to use Threading correctly here?

TIA
Adda

.

Nov 20 '05 #5
Hello Adda
Try Dim p as NEW frmParent = CType(Me.Parent, System.Windows.Forms.Form)
"Adda" <an*******@discussions.microsoft.com> wrote in message
news:15*****************************@phx.gbl...
Hi Ken,

I actually tried something like that a few days ago but
could not get the correct syntax (still in the migration
process from vb6). So I tried it with your syntax, but I
was having an implicit conversion problem since I had
Option Strict On. So I turned it off. Now I get an error
that the specified cast is not valid. So I tried

Dim p as frmParent = CType(Me.Parent,
System.Windows.Forms.Form)

but still having problem with specified cast not valid. I
appologize for my newbieness with .Net (just know that I
hate having to go through the amateur phase all over
again :).

Adda
-----Original Message-----
Hi,

Why are you creating a new frmparent. Why dont

you try

Dim p as frmParent = Me.Parent

Ken
-------------------
"Adda" <an*******@discussions.microsoft.com> wrote in

message
news:1a*****************************@phx.gbl...
I have an mdi form and I am trying to call a procedure -
"myTest" in the parent from the childform. I am
experimenting using a thread, but the thread is not
releasing the childform. I place a breakpoint in "myTest" on the parent form and I have a
msgbox("Done here!") on the childform. The program stops at the breakpoint in "myTest" but does not continue to the msgbox until after I have finished with "myTest". Here is what I have in the childform:
----------------------------------------------
Imports System
Imports System.Threading
...
Public Class childfrm

Private Sub btn_Click(...)...
Dim p As New frmParent
Dim t As New Thread(AddressOf p.myTest())
t.Start()
MsgBox("done here!")
End Sub
End Class
------------------------------------------------
"myTest" runs OK, but not reaching msgbox in childform
until "myTest" is done first.

I also get this message in the output window after running everything:

The thread '<No Name>' (0xb48) has exited with code 0
(0x0).

Am I using the Thread object correctly? Could someone
tell me how to use Threading correctly here?

TIA
Adda

.

Nov 20 '05 #6
Hello Adda
Try Dim p as NEW frmParent = CType(Me.Parent, System.Windows.Forms.Form)
"Adda" <an*******@discussions.microsoft.com> wrote in message
news:15*****************************@phx.gbl...
Hi Ken,

I actually tried something like that a few days ago but
could not get the correct syntax (still in the migration
process from vb6). So I tried it with your syntax, but I
was having an implicit conversion problem since I had
Option Strict On. So I turned it off. Now I get an error
that the specified cast is not valid. So I tried

Dim p as frmParent = CType(Me.Parent,
System.Windows.Forms.Form)

but still having problem with specified cast not valid. I
appologize for my newbieness with .Net (just know that I
hate having to go through the amateur phase all over
again :).

Adda
-----Original Message-----
Hi,

Why are you creating a new frmparent. Why dont

you try

Dim p as frmParent = Me.Parent

Ken
-------------------
"Adda" <an*******@discussions.microsoft.com> wrote in

message
news:1a*****************************@phx.gbl...
I have an mdi form and I am trying to call a procedure -
"myTest" in the parent from the childform. I am
experimenting using a thread, but the thread is not
releasing the childform. I place a breakpoint in "myTest" on the parent form and I have a
msgbox("Done here!") on the childform. The program stops at the breakpoint in "myTest" but does not continue to the msgbox until after I have finished with "myTest". Here is what I have in the childform:
----------------------------------------------
Imports System
Imports System.Threading
...
Public Class childfrm

Private Sub btn_Click(...)...
Dim p As New frmParent
Dim t As New Thread(AddressOf p.myTest())
t.Start()
MsgBox("done here!")
End Sub
End Class
------------------------------------------------
"myTest" runs OK, but not reaching msgbox in childform
until "myTest" is done first.

I also get this message in the output window after running everything:

The thread '<No Name>' (0xb48) has exited with code 0
(0x0).

Am I using the Thread object correctly? Could someone
tell me how to use Threading correctly here?

TIA
Adda

.

Nov 20 '05 #7
Hi,

Dim p as frmParent = CType(Me.Parent, frmParent)

Ken
---------------------
"Adda" <an*******@discussions.microsoft.com> wrote in message
news:15*****************************@phx.gbl...
Hi Ken,

I actually tried something like that a few days ago but
could not get the correct syntax (still in the migration
process from vb6). So I tried it with your syntax, but I
was having an implicit conversion problem since I had
Option Strict On. So I turned it off. Now I get an error
that the specified cast is not valid. So I tried

Dim p as frmParent = CType(Me.Parent,
System.Windows.Forms.Form)

but still having problem with specified cast not valid. I
appologize for my newbieness with .Net (just know that I
hate having to go through the amateur phase all over
again :).

Adda
-----Original Message-----
Hi,

Why are you creating a new frmparent. Why dont

you try

Dim p as frmParent = Me.Parent

Ken
-------------------
"Adda" <an*******@discussions.microsoft.com> wrote in

message
news:1a*****************************@phx.gbl...
I have an mdi form and I am trying to call a procedure -
"myTest" in the parent from the childform. I am
experimenting using a thread, but the thread is not
releasing the childform. I place a breakpoint in "myTest" on the parent form and I have a
msgbox("Done here!") on the childform. The program stops at the breakpoint in "myTest" but does not continue to the msgbox until after I have finished with "myTest". Here is what I have in the childform:
----------------------------------------------
Imports System
Imports System.Threading
...
Public Class childfrm

Private Sub btn_Click(...)...
Dim p As New frmParent
Dim t As New Thread(AddressOf p.myTest())
t.Start()
MsgBox("done here!")
End Sub
End Class
------------------------------------------------
"myTest" runs OK, but not reaching msgbox in childform
until "myTest" is done first.

I also get this message in the output window after running everything:

The thread '<No Name>' (0xb48) has exited with code 0
(0x0).

Am I using the Thread object correctly? Could someone
tell me how to use Threading correctly here?

TIA
Adda

.

Nov 20 '05 #8
Hi,

Dim p as frmParent = CType(Me.Parent, frmParent)

Ken
---------------------
"Adda" <an*******@discussions.microsoft.com> wrote in message
news:15*****************************@phx.gbl...
Hi Ken,

I actually tried something like that a few days ago but
could not get the correct syntax (still in the migration
process from vb6). So I tried it with your syntax, but I
was having an implicit conversion problem since I had
Option Strict On. So I turned it off. Now I get an error
that the specified cast is not valid. So I tried

Dim p as frmParent = CType(Me.Parent,
System.Windows.Forms.Form)

but still having problem with specified cast not valid. I
appologize for my newbieness with .Net (just know that I
hate having to go through the amateur phase all over
again :).

Adda
-----Original Message-----
Hi,

Why are you creating a new frmparent. Why dont

you try

Dim p as frmParent = Me.Parent

Ken
-------------------
"Adda" <an*******@discussions.microsoft.com> wrote in

message
news:1a*****************************@phx.gbl...
I have an mdi form and I am trying to call a procedure -
"myTest" in the parent from the childform. I am
experimenting using a thread, but the thread is not
releasing the childform. I place a breakpoint in "myTest" on the parent form and I have a
msgbox("Done here!") on the childform. The program stops at the breakpoint in "myTest" but does not continue to the msgbox until after I have finished with "myTest". Here is what I have in the childform:
----------------------------------------------
Imports System
Imports System.Threading
...
Public Class childfrm

Private Sub btn_Click(...)...
Dim p As New frmParent
Dim t As New Thread(AddressOf p.myTest())
t.Start()
MsgBox("done here!")
End Sub
End Class
------------------------------------------------
"myTest" runs OK, but not reaching msgbox in childform
until "myTest" is done first.

I also get this message in the output window after running everything:

The thread '<No Name>' (0xb48) has exited with code 0
(0x0).

Am I using the Thread object correctly? Could someone
tell me how to use Threading correctly here?

TIA
Adda

.

Nov 20 '05 #9
Well, I tried this but still getting the casting problem.
The only thing that is working here is

Dim p as New frmParent

My goal is to be able to refresh the datagrid in the
parent form from the childform. I'm sure there is a way,
but I just don't have the proficiency yet with vb.net to
intuit how to accomplish this. Maybe API code? It seems
like only adding data to the dataset from the parent form
does the trick. How can I trick the parent form from the
childform? Oh well, back to the drawing board.

But I thank everyone for all the replies and suggestions.

Adda
-----Original Message-----
Hi,

Dim p as frmParent = CType(Me.Parent, frmParent)

Ken
---------------------
"Adda" <an*******@discussions.microsoft.com> wrote in messagenews:15*****************************@phx.gbl...
Hi Ken,

I actually tried something like that a few days ago but
could not get the correct syntax (still in the migration
process from vb6). So I tried it with your syntax, but I was having an implicit conversion problem since I had
Option Strict On. So I turned it off. Now I get an error that the specified cast is not valid. So I tried

Dim p as frmParent = CType(Me.Parent,
System.Windows.Forms.Form)

but still having problem with specified cast not valid. I appologize for my newbieness with .Net (just know that I
hate having to go through the amateur phase all over
again :).

Adda
>-----Original Message-----
>Hi,
>
> Why are you creating a new frmparent. Why dont
you try
>
>Dim p as frmParent = Me.Parent
>
>Ken
>-------------------
>"Adda" <an*******@discussions.microsoft.com> wrote in

message
>news:1a*****************************@phx.gbl...
>> I have an mdi form and I am trying to call a
procedure - >> "myTest" in the parent from the childform. I am
>> experimenting using a thread, but the thread is not
>> releasing the childform. I place a breakpoint

in "myTest"
>> on the parent form and I have a
>> msgbox("Done here!") on the childform. The program

stops
>> at the breakpoint in "myTest" but does not continue to the
>> msgbox until after I have finished with "myTest".
Here is
>> what I have in the childform:
>> ----------------------------------------------
>> Imports System
>> Imports System.Threading
>> ...
>> Public Class childfrm
>>
>> Private Sub btn_Click(...)...
>> Dim p As New frmParent
>> Dim t As New Thread(AddressOf p.myTest())
>> t.Start()
>> MsgBox("done here!")
>> End Sub
>> End Class
>> ------------------------------------------------
>> "myTest" runs OK, but not reaching msgbox in

childform >> until "myTest" is done first.
>>
>> I also get this message in the output window after

running
>> everything:
>>
>> The thread '<No Name>' (0xb48) has exited with code 0
>> (0x0).
>>
>> Am I using the Thread object correctly? Could someone >> tell me how to use Threading correctly here?
>>
>> TIA
>> Adda
>
>
>.
>

.

Nov 20 '05 #10
Well, I tried this but still getting the casting problem.
The only thing that is working here is

Dim p as New frmParent

My goal is to be able to refresh the datagrid in the
parent form from the childform. I'm sure there is a way,
but I just don't have the proficiency yet with vb.net to
intuit how to accomplish this. Maybe API code? It seems
like only adding data to the dataset from the parent form
does the trick. How can I trick the parent form from the
childform? Oh well, back to the drawing board.

But I thank everyone for all the replies and suggestions.

Adda
-----Original Message-----
Hi,

Dim p as frmParent = CType(Me.Parent, frmParent)

Ken
---------------------
"Adda" <an*******@discussions.microsoft.com> wrote in messagenews:15*****************************@phx.gbl...
Hi Ken,

I actually tried something like that a few days ago but
could not get the correct syntax (still in the migration
process from vb6). So I tried it with your syntax, but I was having an implicit conversion problem since I had
Option Strict On. So I turned it off. Now I get an error that the specified cast is not valid. So I tried

Dim p as frmParent = CType(Me.Parent,
System.Windows.Forms.Form)

but still having problem with specified cast not valid. I appologize for my newbieness with .Net (just know that I
hate having to go through the amateur phase all over
again :).

Adda
>-----Original Message-----
>Hi,
>
> Why are you creating a new frmparent. Why dont
you try
>
>Dim p as frmParent = Me.Parent
>
>Ken
>-------------------
>"Adda" <an*******@discussions.microsoft.com> wrote in

message
>news:1a*****************************@phx.gbl...
>> I have an mdi form and I am trying to call a
procedure - >> "myTest" in the parent from the childform. I am
>> experimenting using a thread, but the thread is not
>> releasing the childform. I place a breakpoint

in "myTest"
>> on the parent form and I have a
>> msgbox("Done here!") on the childform. The program

stops
>> at the breakpoint in "myTest" but does not continue to the
>> msgbox until after I have finished with "myTest".
Here is
>> what I have in the childform:
>> ----------------------------------------------
>> Imports System
>> Imports System.Threading
>> ...
>> Public Class childfrm
>>
>> Private Sub btn_Click(...)...
>> Dim p As New frmParent
>> Dim t As New Thread(AddressOf p.myTest())
>> t.Start()
>> MsgBox("done here!")
>> End Sub
>> End Class
>> ------------------------------------------------
>> "myTest" runs OK, but not reaching msgbox in

childform >> until "myTest" is done first.
>>
>> I also get this message in the output window after

running
>> everything:
>>
>> The thread '<No Name>' (0xb48) has exited with code 0
>> (0x0).
>>
>> Am I using the Thread object correctly? Could someone >> tell me how to use Threading correctly here?
>>
>> TIA
>> Adda
>
>
>.
>

.

Nov 20 '05 #11
Hi Adda,

I was curious if this would work.

I think that it does as you wanted?

(Most code is to build the sample table)

Cor

\\\Mdiform
Private Sub FormMdi_Load(ByVal _
sender As Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
dt.CreateTable()
Dim frm1 As New Form1
frm1.MdiParent = Me
frm1.Show()
Dim frm2 As New Form2
frm2.MdiParent = Me
frm2.Show()
AddHandler dt.dvchanged, AddressOf myrefresh
End Sub
Private Sub myrefresh()
Me.Refresh()
End Sub
///
\\\2 forms form1 and form2 both the same
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
DataGrid1.DataSource = dt.dv
End Sub
///
\\\Class to build a sample table as and to set the events
Public Class dt
Public Shared WithEvents dv As DataView
Public Shared Event dvchanged()
Public Shared Sub CreateTable()
Dim dt As New DataTable("Sample")
For i As Integer = 0 To 7
Dim dc As New DataColumn(Chr(i + 65))
dt.Columns.Add(dc)
Next
For i As Integer = 0 To 8
dt.Rows.Add(dt.NewRow)
For y As Integer = 0 To dt.Columns.Count - 1
dt.Rows(i)(y) = (Chr(i + 48))
Next
Next
dv = New DataView(dt)
End Sub
Private Shared Sub dv_ListChanged(ByVal sender _
As Object, ByVal e As System.ComponentModel.ListChangedEventArgs) _
Handles dv.ListChanged
RaiseEvent dvchanged()
End Sub
End Class
///
Nov 20 '05 #12
Hi Adda,

I was curious if this would work.

I think that it does as you wanted?

(Most code is to build the sample table)

Cor

\\\Mdiform
Private Sub FormMdi_Load(ByVal _
sender As Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
dt.CreateTable()
Dim frm1 As New Form1
frm1.MdiParent = Me
frm1.Show()
Dim frm2 As New Form2
frm2.MdiParent = Me
frm2.Show()
AddHandler dt.dvchanged, AddressOf myrefresh
End Sub
Private Sub myrefresh()
Me.Refresh()
End Sub
///
\\\2 forms form1 and form2 both the same
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
DataGrid1.DataSource = dt.dv
End Sub
///
\\\Class to build a sample table as and to set the events
Public Class dt
Public Shared WithEvents dv As DataView
Public Shared Event dvchanged()
Public Shared Sub CreateTable()
Dim dt As New DataTable("Sample")
For i As Integer = 0 To 7
Dim dc As New DataColumn(Chr(i + 65))
dt.Columns.Add(dc)
Next
For i As Integer = 0 To 8
dt.Rows.Add(dt.NewRow)
For y As Integer = 0 To dt.Columns.Count - 1
dt.Rows(i)(y) = (Chr(i + 48))
Next
Next
dv = New DataView(dt)
End Sub
Private Shared Sub dv_ListChanged(ByVal sender _
As Object, ByVal e As System.ComponentModel.ListChangedEventArgs) _
Handles dv.ListChanged
RaiseEvent dvchanged()
End Sub
End Class
///
Nov 20 '05 #13
Hi,

Dim p as frmParent = DirectCast(Me.MdiParent, frmParent)

Ken
--------------
"Adda" <an*******@discussions.microsoft.com> wrote in message
news:17*****************************@phx.gbl...
Well, I tried this but still getting the casting problem.
The only thing that is working here is

Dim p as New frmParent

My goal is to be able to refresh the datagrid in the
parent form from the childform. I'm sure there is a way,
but I just don't have the proficiency yet with vb.net to
intuit how to accomplish this. Maybe API code? It seems
like only adding data to the dataset from the parent form
does the trick. How can I trick the parent form from the
childform? Oh well, back to the drawing board.

But I thank everyone for all the replies and suggestions.

Adda
-----Original Message-----
Hi,

Dim p as frmParent = CType(Me.Parent, frmParent)

Ken
---------------------
"Adda" <an*******@discussions.microsoft.com> wrote in

message
news:15*****************************@phx.gbl...
Hi Ken,

I actually tried something like that a few days ago but
could not get the correct syntax (still in the migration
process from vb6). So I tried it with your syntax, but I was having an implicit conversion problem since I had
Option Strict On. So I turned it off. Now I get an error that the specified cast is not valid. So I tried

Dim p as frmParent = CType(Me.Parent,
System.Windows.Forms.Form)

but still having problem with specified cast not valid. I appologize for my newbieness with .Net (just know that I
hate having to go through the amateur phase all over
again :).

Adda

>-----Original Message-----
>Hi,
>
> Why are you creating a new frmparent. Why dont you try
>
>Dim p as frmParent = Me.Parent
>
>Ken
>-------------------
>"Adda" <an*******@discussions.microsoft.com> wrote in
message
>news:1a*****************************@phx.gbl...
>> I have an mdi form and I am trying to call a procedure - >> "myTest" in the parent from the childform. I am
>> experimenting using a thread, but the thread is not
>> releasing the childform. I place a breakpoint
in "myTest"
>> on the parent form and I have a
>> msgbox("Done here!") on the childform. The program
stops
>> at the breakpoint in "myTest" but does not continue to the
>> msgbox until after I have finished with "myTest". Here is
>> what I have in the childform:
>> ----------------------------------------------
>> Imports System
>> Imports System.Threading
>> ...
>> Public Class childfrm
>>
>> Private Sub btn_Click(...)...
>> Dim p As New frmParent
>> Dim t As New Thread(AddressOf p.myTest())
>> t.Start()
>> MsgBox("done here!")
>> End Sub
>> End Class
>> ------------------------------------------------
>> "myTest" runs OK, but not reaching msgbox in childform >> until "myTest" is done first.
>>
>> I also get this message in the output window after
running
>> everything:
>>
>> The thread '<No Name>' (0xb48) has exited with code 0
>> (0x0).
>>
>> Am I using the Thread object correctly? Could someone >> tell me how to use Threading correctly here?
>>
>> TIA
>> Adda
>
>
>.
>

.

Nov 20 '05 #14
Hi,

Dim p as frmParent = DirectCast(Me.MdiParent, frmParent)

Ken
--------------
"Adda" <an*******@discussions.microsoft.com> wrote in message
news:17*****************************@phx.gbl...
Well, I tried this but still getting the casting problem.
The only thing that is working here is

Dim p as New frmParent

My goal is to be able to refresh the datagrid in the
parent form from the childform. I'm sure there is a way,
but I just don't have the proficiency yet with vb.net to
intuit how to accomplish this. Maybe API code? It seems
like only adding data to the dataset from the parent form
does the trick. How can I trick the parent form from the
childform? Oh well, back to the drawing board.

But I thank everyone for all the replies and suggestions.

Adda
-----Original Message-----
Hi,

Dim p as frmParent = CType(Me.Parent, frmParent)

Ken
---------------------
"Adda" <an*******@discussions.microsoft.com> wrote in

message
news:15*****************************@phx.gbl...
Hi Ken,

I actually tried something like that a few days ago but
could not get the correct syntax (still in the migration
process from vb6). So I tried it with your syntax, but I was having an implicit conversion problem since I had
Option Strict On. So I turned it off. Now I get an error that the specified cast is not valid. So I tried

Dim p as frmParent = CType(Me.Parent,
System.Windows.Forms.Form)

but still having problem with specified cast not valid. I appologize for my newbieness with .Net (just know that I
hate having to go through the amateur phase all over
again :).

Adda

>-----Original Message-----
>Hi,
>
> Why are you creating a new frmparent. Why dont you try
>
>Dim p as frmParent = Me.Parent
>
>Ken
>-------------------
>"Adda" <an*******@discussions.microsoft.com> wrote in
message
>news:1a*****************************@phx.gbl...
>> I have an mdi form and I am trying to call a procedure - >> "myTest" in the parent from the childform. I am
>> experimenting using a thread, but the thread is not
>> releasing the childform. I place a breakpoint
in "myTest"
>> on the parent form and I have a
>> msgbox("Done here!") on the childform. The program
stops
>> at the breakpoint in "myTest" but does not continue to the
>> msgbox until after I have finished with "myTest". Here is
>> what I have in the childform:
>> ----------------------------------------------
>> Imports System
>> Imports System.Threading
>> ...
>> Public Class childfrm
>>
>> Private Sub btn_Click(...)...
>> Dim p As New frmParent
>> Dim t As New Thread(AddressOf p.myTest())
>> t.Start()
>> MsgBox("done here!")
>> End Sub
>> End Class
>> ------------------------------------------------
>> "myTest" runs OK, but not reaching msgbox in childform >> until "myTest" is done first.
>>
>> I also get this message in the output window after
running
>> everything:
>>
>> The thread '<No Name>' (0xb48) has exited with code 0
>> (0x0).
>>
>> Am I using the Thread object correctly? Could someone >> tell me how to use Threading correctly here?
>>
>> TIA
>> Adda
>
>
>.
>

.

Nov 20 '05 #15
Thank you. This is an interesting approach. I did try it
and got a message that an mdiparent can't be a parent and
also a child. I will experiment with this. Here is the
truth. I am taking a class in ADO.net using VB.net (or
C#). The instructor has a solution, but I won't know it
(until it is too late :). The only thing I can really
think of to evoke something in the parent form would be to
show the childform as a dialog form. But I tried that
only to get the message that only top level forms can be
showed as dialog. In the meantime, I can always read the
contents of the childform from a menu on the parent form.
My instructions are not completely clear (to me) but the
idea is that I add data to a dataset on the parent form
but by clicking a button on the childform and on the
update (from the childform) the datagrid gets refreshed
(also from the button click on the childform).

Adda

-----Original Message-----
Hi Adda,

I was curious if this would work.

I think that it does as you wanted?

(Most code is to build the sample table)

Cor

\\\Mdiform
Private Sub FormMdi_Load(ByVal _
sender As Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
dt.CreateTable()
Dim frm1 As New Form1
frm1.MdiParent = Me
frm1.Show()
Dim frm2 As New Form2
frm2.MdiParent = Me
frm2.Show()
AddHandler dt.dvchanged, AddressOf myrefresh
End Sub
Private Sub myrefresh()
Me.Refresh()
End Sub
///
\\\2 forms form1 and form2 both the same
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
DataGrid1.DataSource = dt.dv
End Sub
///
\\\Class to build a sample table as and to set the events
Public Class dt
Public Shared WithEvents dv As DataView
Public Shared Event dvchanged()
Public Shared Sub CreateTable()
Dim dt As New DataTable("Sample")
For i As Integer = 0 To 7
Dim dc As New DataColumn(Chr(i + 65))
dt.Columns.Add(dc)
Next
For i As Integer = 0 To 8
dt.Rows.Add(dt.NewRow)
For y As Integer = 0 To dt.Columns.Count - 1
dt.Rows(i)(y) = (Chr(i + 48))
Next
Next
dv = New DataView(dt)
End Sub
Private Shared Sub dv_ListChanged(ByVal sender _
As Object, ByVal e As System.ComponentModel.ListChangedEventArgs) _ Handles dv.ListChanged
RaiseEvent dvchanged()
End Sub
End Class
///
.

Nov 20 '05 #16
Thank you. This is an interesting approach. I did try it
and got a message that an mdiparent can't be a parent and
also a child. I will experiment with this. Here is the
truth. I am taking a class in ADO.net using VB.net (or
C#). The instructor has a solution, but I won't know it
(until it is too late :). The only thing I can really
think of to evoke something in the parent form would be to
show the childform as a dialog form. But I tried that
only to get the message that only top level forms can be
showed as dialog. In the meantime, I can always read the
contents of the childform from a menu on the parent form.
My instructions are not completely clear (to me) but the
idea is that I add data to a dataset on the parent form
but by clicking a button on the childform and on the
update (from the childform) the datagrid gets refreshed
(also from the button click on the childform).

Adda

-----Original Message-----
Hi Adda,

I was curious if this would work.

I think that it does as you wanted?

(Most code is to build the sample table)

Cor

\\\Mdiform
Private Sub FormMdi_Load(ByVal _
sender As Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
dt.CreateTable()
Dim frm1 As New Form1
frm1.MdiParent = Me
frm1.Show()
Dim frm2 As New Form2
frm2.MdiParent = Me
frm2.Show()
AddHandler dt.dvchanged, AddressOf myrefresh
End Sub
Private Sub myrefresh()
Me.Refresh()
End Sub
///
\\\2 forms form1 and form2 both the same
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
DataGrid1.DataSource = dt.dv
End Sub
///
\\\Class to build a sample table as and to set the events
Public Class dt
Public Shared WithEvents dv As DataView
Public Shared Event dvchanged()
Public Shared Sub CreateTable()
Dim dt As New DataTable("Sample")
For i As Integer = 0 To 7
Dim dc As New DataColumn(Chr(i + 65))
dt.Columns.Add(dc)
Next
For i As Integer = 0 To 8
dt.Rows.Add(dt.NewRow)
For y As Integer = 0 To dt.Columns.Count - 1
dt.Rows(i)(y) = (Chr(i + 48))
Next
Next
dv = New DataView(dt)
End Sub
Private Shared Sub dv_ListChanged(ByVal sender _
As Object, ByVal e As System.ComponentModel.ListChangedEventArgs) _ Handles dv.ListChanged
RaiseEvent dvchanged()
End Sub
End Class
///
.

Nov 20 '05 #17
Hi Adda,

I did test that sample and did not get an error, did you set the mdi = true
in the mdi form that I did using the designer?

Cor
Nov 20 '05 #18
Hi Adda,

I did test that sample and did not get an error, did you set the mdi = true
in the mdi form that I did using the designer?

Cor
Nov 20 '05 #19

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: AMS | last post by:
I am trying to create a thread to execute a script for me and then display the output in notepad. What is happening is when I call the CreateThread method and pass in the Routine and Parameter...
5
by: me | last post by:
I have a Class Library that contains a Form and several helper classes. A thread gets created that performs processing of data behind the scenes and the Form never gets displayed (it is for debug...
6
by: SamIAm | last post by:
Hi am creating a email application that needs to mail out a very large amount of emails. I have created a multithreaded c# application that using message queuing. I have created a threadpool of 5...
4
by: MechSoft | last post by:
Hi, there, I have a multi-threaded non-MFC program that will include a regular dll which would be part of the user interface, possibly a dialog based interface. I would prefer to have the user...
2
by: Markus Prediger | last post by:
Hi NG, I have an asp.net project that uses an vb6 com object for some database-manipulation (I cannot rewrite it in .net, sorry, its not my decision). I want it to be instanciated seperately...
7
by: Roemer | last post by:
Hi all I stumbled over a new problem: I have a programm with just a class that is asynchronous listening for network connections. As soon as someone connected, a new form needs to be created....
3
by: Erakis | last post by:
Hi, I have to make an ActiveX (Running on Internet Explorer) that play/record sound from soundcard. Also, I have to create a Socket to send/receive sound data to my server. I use this...
11
by: raylopez99 | last post by:
Keep in mind this is my first compiled SQL program Stored Procedure (SP), copied from a book by Frasier Visual C++.NET in Visual Studio 2005 (Chap12). So far, so theory, except for one bug...
0
by: =?Utf-8?B?QmFydE1hbg==?= | last post by:
Greetings, To begin with we have an archetecture which has a manager Asssembly which loads "Plug-in" assemblies using reflection, when a the UI prompts the manager. This loading of the...
2
by: jarea | last post by:
I have read quite a bit about this error but I have yet to find the solution to my problem. I am trying to execute the following mysql statement: alter table line_items add...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.