473,569 Members | 2,703 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Making main form unclickable during from UI Update

6 New Member
I have a server applicatoin that has a multitude of labels related to the clients connected to it. When I have a number near 50 clients and i recieve a updatated status from each of the clients at once the labels are updated to the current status. (basically a label color is changed depending on status), this operation causes the mainform to freeze until it can process all of the messages recieved.

I have tried everything possible to make the form update asyncronously without this hang but cannot get it to work. Since each client thread runs the same update function i placed in a multitude of invoke code to make it update but there has been no change.

So my next idea was to make the from unclickable until its ready but am unsure how to do this? anyone got any ideas?

example of process:

Expand|Select|Wrap|Line Numbers
  1. server:
  2. sendtoclients("GETSTATUS")
  3. client:
  4. client("RETURNSTATUS|GREEN")
  5. server:
  6. case "RETURNSTATUS"
  7.                          If Not statusdict.ContainsKey(sender.WS) Then
  8.                         statusdict.Add(sender.WS, dataArray(1))
  9.                     Else
  10.                         statusdict.Item(sender.WS) = dataArray(1)
  11.                     End If
  12.                     '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  13.                     UpdateUI()
  14.                     TargetHandler.BeginInvoke(CallbackHandler, Nothing)
  15.  
  16. '''''old method call   'readstatusdictoinary()
  17. end select
  18.  
  19. sub readstatusentry()
  20. Dim entry As DictionaryEntry
  21.  
  22.         Dim comp As String
  23.         Dim status As String
  24.         Dim ILoop As Integer = 0
  25.         Dim ALoop As Integer = 0
  26.         Dim green As Integer = 0
  27.         Dim red As Integer = 0
  28.  
  29.         'nulls(display)
  30.         loggedInLabel.Text = "0"
  31.         LockedLabel.Text = "0"
  32.  
  33.         'HERE is where it changes label color
  34.         Try
  35.             For Each entry In New System.Collections.Hashtable(statusdict)
  36.                 ALoop = 0
  37.                 comp = entry.Key.ToString
  38.                 status = entry.Value.ToString
  39.                 For ILoop = 0 To 69
  40.                     If comp = LabelArray(ALoop).Text Then
  41.                         Select Case status.ToLower
  42.                             Case "red"
  43.                                 LabelArray(ALoop).BackColor = Color.Red
  44.                                 red = red + 1
  45.                                 green = green - 1
  46.                                 lockedlabel.Text = red.ToString
  47.                             Case "green"
  48.                                 LabelArray(ALoop).BackColor = Color.Green
  49.                                 green = green + 1
  50.                                 red = red - 1
  51.                                 loggedInLabel.Text = green.ToString
  52.                             End Select
  53.                         PNRLabel.Text = gray.ToString
  54.                     End If
  55.                     ALoop = ALoop + 1
  56.                 Next
  57.             Next
  58.         Catch ex As Exception
  59.             MsgBox(ex.ToString)
  60.         End Try
  61. end sub
  62.  
  63.  
  64.  
  65.     '*** create delegate object to execute method asynchronously
  66.     Private TargetHandler As readstatusentryHandler _
  67.                              = AddressOf readstatusentry
  68.  
  69.     '*** create delegate object to service callback from CLR
  70.     Private CallbackHandler As AsyncCallback _
  71.                                = AddressOf MyCallbackMethod
  72.  
  73.     '*** callback method runs on worker thread and not the UI thread
  74.     Sub MyCallbackMethod(ByVal ar As IAsyncResult)
  75.         Try
  76.  
  77.             UpdateUI()
  78.         Catch ex As Exception
  79.  
  80.             MsgBox("Error: " & ex.Message)
  81.             UpdateUI()
  82.         End Try
  83.     End Sub
  84.  
  85.     '*** can be called from any method on form to update UI
  86.     Sub UpdateUI()
  87.         '*** check to see if thread switch is required
  88.         If Me.InvokeRequired Then
  89.             Dim handler As New UpdateUIHandler(AddressOf readstatusentry)
  90.  
  91.             Me.BeginInvoke(handler)
  92.         Else
  93.             readstatusentry()
  94.         End If
  95.     End Sub
  96.  
  97.     '*** delegate used to switch control over to primary UI thread
  98.     Delegate Sub UpdateUIHandler()
  99.     Delegate Sub readstatusentryHandler()
Mar 11 '08 #1
6 2355
kadghar
1,295 Recognized Expert Top Contributor
...

So my next idea was to make the from unclickable until its ready but am unsure how to do this? anyone got any ideas? ...
Couldn't you just disable it?

Expand|Select|Wrap|Line Numbers
  1. me.enabled=false
Mar 11 '08 #2
85ssp
6 New Member
Couldn't you just disable it?

Expand|Select|Wrap|Line Numbers
  1. me.enabled=false

where should I disable it? if i disable the form at the begining of readstatusentry and then enable it at the end, when another client calls function it will just run the code again and again and again. Just like changing the label color.
Mar 11 '08 #3
85ssp
6 New Member
i went ahead and instituted a counter to count the cleint messages and then update the form, this works in a specific circumstance when the server comes up and individual clients connect.

If the server crashes, and you relaunch the server, all clients try to connect at once and the server is not recieving all of the transmissions, roughly missing 3 clients.

Anyone have any idea on how i may go about solving this.
Mar 13 '08 #4
Sick0Fant
121 New Member
Maybe there's something I'm not understanding, but can't you just create an event and listen for it in your main form?
Mar 13 '08 #5
Killer42
8,435 Recognized Expert Expert
Wouldn't it make sense to have a timer update the labels periodically, independently of when the messages are received? Perhaps once per second, or whatever seems appropriate.
Mar 14 '08 #6
85ssp
6 New Member
I went ahead and institiuted a timer to update the ui, but i dont believe this to be my issue now, it appears the server is dropping messages sent to it over the network, basically not recieving everything it needs too when 50 clients send at the same time, any idea how to clear this up? I'm transmitting on port 6000, could this be the issue?
Mar 17 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
393
by: | last post by:
Is there anyway to update a control held on my main form from a child form? I've tried making the control itself public but I still can't seem to access it
9
3320
by: William Wisnieski | last post by:
Hello Everyone, Access 2000 I have a main form with a continuous subform. On the main form I have a text field called . It gets populated based on what the user selects in a field on the sub form (code in the AfterUpdate Event). Here's the issue. If the user deletes a subform record. The field on the main form shows null even if...
30
8880
by: Shannan Casteel via AccessMonster.com | last post by:
I have a subform named "sbfrmParts" with a list of parts along with the quantity and price. I have used a text box in the subform's footer and set the control source to "=Sum(*)". I set the format to display currency. This text box is called "SubformTotal", and is visible property is set to "No". On the main form I have made another text...
3
13978
by: gsb58 | last post by:
Hi! A mainform is being used to show records from a table in an sql database. A button on the main form will load a new form that allows the user to add, delete, update and search certain records in the underlying table of the main form. My question:
22
3048
by: Zytan | last post by:
I have public methods in a form. The main form calls them, to update that form's display. This form is like a real-time view of data that is changing. But, the form may not exist (it is created / destroyed at user request). I can check form != null to prevent incorrect access. But, the form could disappear immediately after the check,...
16
34464
by: mlcampeau | last post by:
I'm fairly new to this so I'll try to be as clear as possible. I have a database that stores employee information and all job titles available. I have a main form that is based from a query and displays all job codes and job titles in the Job table. I also have a text box in the main form to keep track of the total number of positions available...
4
1848
by: Scotter | last post by:
Hello. I'm having problems understanding how to calculate a total on my main form based on the items in my subform. I've tried runing update querys and thats not working, and Ive tried just calculating within the form, and thats not working correctly either. My main form is called Form1, and my subform is testquery2_subform. Whats...
1
1843
by: c0l0nelFlagg | last post by:
I need to display a main form with 48 identical subforms. 6 columns with 8 rows. I set up a separate query for each subform, identical in structure and underlying data except the criteria in two fields is different for each. (ie Row and Column id fields). I am able to select data in each subform from combo box lists, then on after...
0
1488
by: farid121 | last post by:
I am trying to update the main form with each record in the subform. I have two tables Invoice and Payment table. The main form has the payment details which I need to update for each invoice selectedon the subform. EG Invoice Table (SubForm) Ref no , Inv No , Amt 1 , 101 , 10.00 2 , 102...
0
7695
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, 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...
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7922
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, 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. ...
0
8119
jinu1996
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...
1
7668
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...
0
7964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5509
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
2111
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
1
1209
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.