Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / May 2006

Tip: Looking for answers? Try searching our database.

Threading -

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Leo W. - 23 May 2006 04:30 GMT
Hi everyone,

I would appreciate any help concerning this threading issue.
I am using the comm port, and receiving data from the comm port fine.
I am updating the system.form controls, text boxes, using "begininvoke" and
the updates occur, no problem.
However after the update,, the form is about as responsive as a herd of
turtles running through peanut butter.  What am I missing?
Here is the code:

GENERAL:
Public Class Form1
   Inherits System.Windows.Forms.Form
   Private Shared m_FormDefInstance As Form1
...
etc.

-------------------------------------------
Form1 Load event:
 m_FormDefInstance = Me
etc.
------------------------------------------

Comm port:----------------------------
Private Sub m_CommPort_DataReceived(ByVal sender As Object, _
         ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles
m_CommPort.DataReceived

       Dim strModemRecBuffer As String = ""
       strModemRecBuffer = m_CommPort.ReadExisting
       'Update MAINFORM Controls
       m_FormDefInstance.BeginInvoke(New _
         DisplayData(AddressOf ProcessCallerData), _
                 New Object() {strModemRecBuffer})
   End Sub
------------------------------------------------------------

   Public Delegate Sub DisplayData(ByVal strCallerIdDataBuffer As String)

   Private Sub ProcessCallerData(ByVal strCallerIdDataBuffer As String)
       'Update the text box with caller-id (Works fine)
       ' I do some formatting for the <Cr> in the caller-id fields, but
       'that is all working fine
       text1.text = strCallerIdDataBuffer
       text1.refresh
end sub

The caller-id data comes out fine, and then the form goes to slug mode.
Any help would be appreciated, thank-you in advance
Am I missing something with the thread?
Dmytro Lapshyn [MVP] - 23 May 2006 09:10 GMT
Hi Leo,

Blind guess - try removing the "text.refresh" line from the
ProcessCallerData subroutine.

> Hi everyone,
>
[quoted text clipped - 47 lines]
> Any help would be appreciated, thank-you in advance
> Am I missing something with the thread?
Leo W. - 23 May 2006 10:07 GMT
Hi Dmytro,

I tried your suggestion, and same problem.
But you got me thinking about the "properties" of the textbox.

I don't understand why, but when I changed the property of the textbox to
"Readonly=TRUE" from the IDE and then in the program
(After the DataReceivedEventFires) And In The Sub (ProcessCallerId)
(1) Change it to false
(2) Update it for the Caller-Id
(3) Set it back to ReadOnly =TRUE
Then it seems, (I say seems because I want to test and test before I call it
done)
Then the program is responsive (ie,all functions of program work fine so
far...)

Any ideas why this would (Seem) to eliminate the problem?
Could it be doing something in the thread with the property set to TRUE.

Leo

> Hi Leo,
>
[quoted text clipped - 52 lines]
> > Any help would be appreciated, thank-you in advance
> > Am I missing something with the thread?
Dmytro Lapshyn [MVP] - 24 May 2006 08:16 GMT
Hmmm.. that's really weird... a textbox being R/O or not, this has
absolutely nothing to do with threading.
Here's another suggestion - replace BeginInvoke with Invoke. Updating the
textbox' contents should be quick, so I think it is OK if the worker thread
stops and waits while the textbox' value is updated.

If the problem persists, try a profiler (I recall there was a freeware one).

> Hi Dmytro,
>
[quoted text clipped - 76 lines]
>> > Any help would be appreciated, thank-you in advance
>> > Am I missing something with the thread?
Leo W. - 24 May 2006 09:04 GMT
> Here's another suggestion - replace BeginInvoke with Invoke. Updating the
> textbox' contents should be quick, so I think it is OK if the worker thread
> stops and waits while the textbox' value is updated.

I'll try this thanks for the suggestion.

A little further update, I have been testing it today, and...

1. If I DO NOT click inside the text box (Any of the textboxes that I have
updated in the second thread, using the begin.invoke the program works ok, so
far)

2. If I click in ANY of the textboxes (That were updated in the thread),
then the  program goes un-responsive.

I'll try your suggestion and let you know.
Thanks, Leo

> If the problem persists, try a profiler (I recall there was a freeware one).
>
[quoted text clipped - 78 lines]
> >> > Any help would be appreciated, thank-you in advance
> >> > Am I missing something with the thread?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.