Hello and thank you for your assistance.
I have attempted to accomplish what I need using delegates with no success.
i.e.
//Button Click//
Dim PollThread As Threading.Threa d
PollThread = New Threading.Threa d(AddressOf PollThreadAddre ss)
PollThread.Star t()
End Sub
Private Sub PollThreadAddre ss()
frm1PollDatabas e.TopMost = True
frm1PollDatabas e.ShowDialog()
End Sub
//Button Click inside frm1PollDatabas e that raises an event inside the
Parent Form//
Delegate Sub FromMyPage()
Dim MyDeleg As FromMyPage
Private Sub ApplyMyPage
MyDeleg = New FromMyPage(Addr essOf DelegateFromMyP age)
MyDeleg.Invoke( )
End Sub
Private Sub DelegateFromMyP age()
frm1Modify.show dialog
End Sub
** frm1PollDatabas e is created inside a new thread and must always be on
top, which works fine. But when the user wants to send that data from this
form to a new form (frm1Modify) the form is displayed but frm1PollDatabas e
becomes disabled because of the Showdialog method. I cannot use show for
this form to be displayed. If the original thread (Main) displays this form
wont it prevent this problem? The above code did not keep frm1PollDatabas e
from being disabled.
Thanks Again,
Chuck 4 1602
"Charles A. Lackman" <Ch*****@Create ItSoftware.net> wrote in message
news:Oy******** ******@TK2MSFTN GP12.phx.gbl... Hello and thank you for your assistance.
I have attempted to accomplish what I need using delegates with no success. i.e.
//Button Click// Dim PollThread As Threading.Threa d PollThread = New Threading.Threa d(AddressOf PollThreadAddre ss) PollThread.Star t() End Sub
Private Sub PollThreadAddre ss() frm1PollDatabas e.TopMost = True frm1PollDatabas e.ShowDialog() End Sub
//Button Click inside frm1PollDatabas e that raises an event inside the Parent Form// Delegate Sub FromMyPage() Dim MyDeleg As FromMyPage
Private Sub ApplyMyPage MyDeleg = New FromMyPage(Addr essOf DelegateFromMyP age) MyDeleg.Invoke( ) End Sub
Private Sub DelegateFromMyP age() frm1Modify.show dialog End Sub
** frm1PollDatabas e is created inside a new thread and must always be on top, which works fine. But when the user wants to send that data from this form to a new form (frm1Modify) the form is displayed but frm1PollDatabas e becomes disabled because of the Showdialog method. I cannot use show for this form to be displayed. If the original thread (Main) displays this form wont it prevent this problem? The above code did not keep frm1PollDatabas e from being disabled.
All of your UI code needs to be on one thread. That's probably the problem.
John Saunders
You seem to be breaking the golden rule of threading in Windows Forms
applications: never touch UI objects from any thread other than the thread
on which they were created.
This article discusses how to use multiple threads safely (i.e. without
breaking this rule) in a Windows Forms application: http://msdn.microsoft.com/msdnmag/is...ultithreading/
There's also a good discussion here: http://www.yoda.arachsys.com/csharp/...winforms.shtml
In fact if you plan on doing any multithreaded development in Windows Forms,
I'd recommend you read all of Jon Skeet's threading articles: http://www.yoda.arachsys.com/csharp/threads/
You really need to understand pretty much all of the topics he covers in
these articles before you'll be able to write reliable multithreaded code in
..NET.
--
Ian Griffiths - http://www.interact-sw.co.uk/iangblog/
DevelopMentor - http://www.develop.com/
"Charles A. Lackman" wrote: Hello and thank you for your assistance.
I have attempted to accomplish what I need using delegates with no success. i.e.
//Button Click// Dim PollThread As Threading.Threa d PollThread = New Threading.Threa d(AddressOf PollThreadAddre ss) PollThread.Star t() End Sub
Private Sub PollThreadAddre ss() frm1PollDatabas e.TopMost = True frm1PollDatabas e.ShowDialog() End Sub
//Button Click inside frm1PollDatabas e that raises an event inside the Parent Form// Delegate Sub FromMyPage() Dim MyDeleg As FromMyPage
Private Sub ApplyMyPage MyDeleg = New FromMyPage(Addr essOf DelegateFromMyP age) MyDeleg.Invoke( ) End Sub
Private Sub DelegateFromMyP age() frm1Modify.show dialog End Sub
** frm1PollDatabas e is created inside a new thread and must always be on top, which works fine. But when the user wants to send that data from this form to a new form (frm1Modify) the form is displayed but frm1PollDatabas e becomes disabled because of the Showdialog method. I cannot use show for this form to be displayed. If the original thread (Main) displays this form wont it prevent this problem? The above code did not keep frm1PollDatabas e from being disabled.
Charles,
Did I ever showed you this sample of my.
Before you become confuse about it, be aware this that it shows two the same
forms (form2), one with multithreading and one without.
Normally I send only the Google link, however I have the idea Google has
since today shorten his newsgroup service and is it not possible anymore to
show only one message.
\\\needs on form 1 one button and three textboxes
Private WithEvents frm1 As Form2
Private Delegate Sub Frm1Handler(ByV al message As String)
Private WithEvents frm2 As Form2
Private MyThread As System.Threadin g.Thread
Private Sub Form1_Load(ByVa l sender As Object, _
ByVal e As System.EventArg s) Handles MyBase.Load
Dim timer1 As New System.Windows. Forms.Timer
AddHandler timer1.Tick, AddressOf mytimer1
TextBox1.Text = "0"
timer1.Enabled = True
timer1.Interval = 400
Dim timer2 As New System.Windows. Forms.Timer
End Sub
Private Sub mytimer1(ByVal sender As Object, _
ByVal e As System.EventArg s)
TextBox1.Text = (CInt(TextBox1. Text) + 1).ToString
DirectCast(send er, System.Windows. Forms.Timer).En abled = True
End Sub
Private Sub Button1_Click(B yVal sender As System.Object, _
ByVal e As System.EventArg s) Handles Button1.Click
frm1 = New Form2
frm1.itstop = Me.Top
frm1.itsleft = Me.Left + 200
AddHandler frm1.ready, AddressOf Frm1Ready
frm1.Text = "Extra thread"
MyThread = New System.Threadin g.Thread(Addres sOf frm1.Show)
MyThread.Start( )
frm2 = New Form2
frm2.itstop = Me.Top
frm2.itsleft = Me.Left + 400
frm2.Text = "In own thread"
AddHandler frm1.ready, AddressOf Frm2Ready
frm2.Show()
End Sub
Private Sub Frm1Ready(ByVal message As String)
Me.BeginInvoke( New Frm1Handler(Add ressOf Frm1HandlerSub) , New
Object() {message})
End Sub
Private Sub Frm1HandlerSub( ByVal message As String)
TextBox2.Text = message
frm1.Close()
MyThread.Abort( )
End Sub
Private Sub frm2ready(ByVal message As String)
TextBox3.Text = message
frm2.Dispose()
End Sub
Private Sub Form1_Closing(B yVal sender As Object, _
ByVal e As System.Componen tModel.CancelEv entArgs) Handles MyBase.Closing
MyThread.Abort( )
End Sub
///
\\\Needs a form2 with one textbox
Friend Event ready(ByVal message As String)
Friend itstop As Integer
Friend itsleft As Integer
Private Sub Form2_Activated (ByVal sender As Object, _
ByVal e As System.EventArg s) Handles MyBase.Activate d
Me.Left = itsleft
Me.Top = itstop
Me.BringToFront ()
Dim timenext As DateTime = Now.Add(TimeSpa n.FromSeconds(1 0))
Do While timenext > Now
TextBox1.Text = Now.TimeOfDay.T oString
Application.DoE vents() 'to show the time
Threading.Threa d.Sleep(50)
Me.Opacity -= 0.004
Loop
RaiseEvent ready(Now.TimeO fDay.ToString)
End Sub
Private Sub Form2_Closing(B yVal sender As Object, ByVal _
e As System.Componen tModel.CancelEv entArgs) Handles MyBase.Closing
e.Cancel = True
End Sub
///
I hope this helps a little bit?
Cor
"Cor Ligthert" <no************ @planet.nl> schrieb: Normally I send only the Google link, however I have the idea Google has since today shorten his newsgroup service and is it not possible anymore to show only one message.
That's still possible:
Click the "Show original" link of the message, for example:
<URL:http://groups-beta.google.com/group/microsoft.publi c.dotnet.langua ges.vb/msg/84779a2037f1cae 6?dmode=source>
Then remove the "?dmode=sou rce" part.
Notice that these links have one drawback: The URL will change in future
when the new groups interface will be released, so URLs will certainly
break. Another alternative is using the German interface for Google Groups
which is still the "old" version.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Anthony_Barker |
last post by:
I have been reading a book about the evolution of the Basic
programming language. The author states that Basic - particularly
Microsoft's version is full of compromises which crept in along the
language's 30+ year evolution.
What to you think python largest compromises are?
The three that come to my mind are significant whitespace, dynamic
typing, and that it is interpreted - not compiled. These three put
python under fire and cause...
|
by: Jane Austine |
last post by:
As far as I know python's threading module models after Java's.
However, I can't find something equivalent to Java's interrupt and
isInterrupted methods, along with InterruptedException.
"somethread.interrupt()" will wake somethread up when it's in
sleeping/waiting state.
Is there any way of doing this with python's thread? I suppose thread
interrupt is a very primitive functionality for stopping a blocked
thread.
|
by: Elliot Rodriguez |
last post by:
Hi:
I am writing a WinForm app that contains a DataGrid control and a StatusBar
control. My goal is to update the status bar using events from a separate
class, as well as some other simple things.
The method I am writing queries a large dataset. As part of my feedback to
the user, I am updating the status bar when the connection is made and the
dataset is actually retrieved. The dataset retrieval method I have placed on
a separate...
|
by: Anthony Nystrom |
last post by:
What is the correct way to stop a thread? abort? sleep? Will it start up
again... Just curious... If the thread is enabling a form, if the form is
disposed is the thread as well?
Thanks,
Anthony Nystrom
|
by: Pawan Narula via DotNetMonster.com |
last post by:
hi all,
i'm using VB.NET and trying to code for contact management in a tree. all my contacts r saved in a text file and my C dll reads them one by one and sends to VB callback in a sync mode thread. so far so good. all contacts r added properly.
now when another login adds me in his contact, i recv a subscription, so i popup a form and ask for accept/reject. this all happens in a separate thread. popup form gets opened and choice is...
| |
by: Aleksandar Cikota |
last post by:
Hi all,
I have a problem with threading. The following part should be running in a
main programm all the time, but so that the main programm also works (like 2
seperate programms, but in one)
How to integrate the Code-part in the main programm, so that the
mainprogramm works?
Code:
|
by: kingcrowbar.list |
last post by:
Hello Everyone
I have been playing a little with pyGTK and threading to come up with
simple alert dialog which plays a sound in the background. The need for
threading came when in the first version i made, the gui would freeze
after clicking the close button until pygame finished playing the
sound.
In Windows it was acceptable because it could be ignored easily, but in
|
by: Bryan |
last post by:
Im new to threading and am experiencing some confusion as to how to
correctly use AfxBeginThread in my singleton class. The code that I
want to thread out is in a single function, Init(). Is AfxBeginThread
the right way to thread off a single worker thread? It seems like it.
But what are the correct args for it, my code wont compile. And does my
class need to be restructured? How?
Thanks,
Bryan
|
by: Sebouh |
last post by:
Hi guys. I was messing with Threading and stuff, and i have reached a point where i'm not sure what's causing the current behavior.
Here's the code:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim nt As New newThread(Me)
Dim t As New Threading.Thread(AddressOf nt.ThreadCode)
t.Start()
End Sub
|
by: Dann Corbit |
last post by:
Rather than create a new way of doing things:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2497.html
why not just pick up ACE into the existing standard:
http://www.cse.wustl.edu/~schmidt/ACE.html
the same way that the STL (and subsequently BOOST) have been subsumed?
Since it already runs on zillions of platforms, they have obviously worked
most of the kinks out of the generalized threading and processes idea (along
with many...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |