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: - server:
-
sendtoclients("GETSTATUS")
-
client:
-
client("RETURNSTATUS|GREEN")
-
server:
-
case "RETURNSTATUS"
-
If Not statusdict.ContainsKey(sender.WS) Then
-
statusdict.Add(sender.WS, dataArray(1))
-
Else
-
statusdict.Item(sender.WS) = dataArray(1)
-
End If
-
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
-
UpdateUI()
-
TargetHandler.BeginInvoke(CallbackHandler, Nothing)
-
-
'''''old method call 'readstatusdictoinary()
-
end select
-
-
sub readstatusentry()
-
Dim entry As DictionaryEntry
-
-
Dim comp As String
-
Dim status As String
-
Dim ILoop As Integer = 0
-
Dim ALoop As Integer = 0
-
Dim green As Integer = 0
-
Dim red As Integer = 0
-
-
'nulls(display)
-
loggedInLabel.Text = "0"
-
LockedLabel.Text = "0"
-
-
'HERE is where it changes label color
-
Try
-
For Each entry In New System.Collections.Hashtable(statusdict)
-
ALoop = 0
-
comp = entry.Key.ToString
-
status = entry.Value.ToString
-
For ILoop = 0 To 69
-
If comp = LabelArray(ALoop).Text Then
-
Select Case status.ToLower
-
Case "red"
-
LabelArray(ALoop).BackColor = Color.Red
-
red = red + 1
-
green = green - 1
-
lockedlabel.Text = red.ToString
-
Case "green"
-
LabelArray(ALoop).BackColor = Color.Green
-
green = green + 1
-
red = red - 1
-
loggedInLabel.Text = green.ToString
-
End Select
-
PNRLabel.Text = gray.ToString
-
End If
-
ALoop = ALoop + 1
-
Next
-
Next
-
Catch ex As Exception
-
MsgBox(ex.ToString)
-
End Try
-
end sub
-
-
-
-
'*** create delegate object to execute method asynchronously
-
Private TargetHandler As readstatusentryHandler _
-
= AddressOf readstatusentry
-
-
'*** create delegate object to service callback from CLR
-
Private CallbackHandler As AsyncCallback _
-
= AddressOf MyCallbackMethod
-
-
'*** callback method runs on worker thread and not the UI thread
-
Sub MyCallbackMethod(ByVal ar As IAsyncResult)
-
Try
-
-
UpdateUI()
-
Catch ex As Exception
-
-
MsgBox("Error: " & ex.Message)
-
UpdateUI()
-
End Try
-
End Sub
-
-
'*** can be called from any method on form to update UI
-
Sub UpdateUI()
-
'*** check to see if thread switch is required
-
If Me.InvokeRequired Then
-
Dim handler As New UpdateUIHandler(AddressOf readstatusentry)
-
-
Me.BeginInvoke(handler)
-
Else
-
readstatusentry()
-
End If
-
End Sub
-
-
'*** delegate used to switch control over to primary UI thread
-
Delegate Sub UpdateUIHandler()
-
Delegate Sub readstatusentryHandler()
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?
Couldn't you just disable it?
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.
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.
Maybe there's something I'm not understanding, but can't you just create an event and listen for it in your main form?
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.
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?
Sign in to post your reply or Sign up for a free account.
Similar topics |
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
|
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...
|
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...
|
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:
|
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,...
| |
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...
|
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...
|
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...
|
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...
|
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...
|
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...
| |
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. ...
|
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...
|
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...
|
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...
|
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...
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |