473,379 Members | 1,187 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,379 software developers and data experts.

Making main form unclickable during from UI Update

6
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 2339
kadghar
1,295 Expert 1GB
...

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
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
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 100+
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 Expert 8TB
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
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
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
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...
30
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...
3
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...
22
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...
16
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...
4
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...
1
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...
0
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?

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.