|
You're welcome. Glad to help out.
It seems that WaitForInputIdle() applies only to process with a UI but there may also be other conditions which cause it to return false. You might want to consider uisng the WaitForInputIdle(Int32) overload since the version you are calling has the potential to wait forever. Also, if for some reason the process doesn't have a message loop, both overloads will immediately return false, so you might want to test the return value as well.
Scott.
—In just two days, tomorrow will be yesterday.
—Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
[ Forum Guidelines] [ Articles] [ Blog]
|
|
|
|
|
Hello,
I am running an experiment which I call VB four different functions I wrote to measure transitor characteristics. I want to display on the form which measurement I am doing. I went about doing this by creating a textbox on the form and then assigning the name of the measurement to the textbox value right before each of the four measurements was done.
The problem is that only the name of the last measurement is displayed after all four measurements are done.
I think it might be because VB is single thread.
Is there some function I can use to update the form?
Thanks,
Orlando
|
|
|
|
|
Hi,
the effects of GUI changes that you order in an event handler typically will show
up only after that handler has exited, so if you set 4 different text values to a
single control, it will only show the last one.
There are a few solutions to this:
1.
the universal approach is to somehow split the actions, e.g. by adding at least one
thread (and then that thread is not allowed to access your GUI elements, so you
have to start using Control.InvokeRequired and Control.Invoke).
2.
another way to slice the job is by using a Windows.Forms.Timer; it will tick periodically
on the GUI thread, so it is allowed to access your Controls.
3.
a quick hack is to leave all as is and to include Application.DoEvents() statements
everytime you want immediate GUI results; this however is dangerous: if your handler
ever gets called recursively, a stack overflow may result. Example: a long handler
might restart if you press the button again before its first action has finished,
since every DoEvents() looks for Windows messages AS IF everything that has already
been started also has finished.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
How do I select a particular selected Value using a list view control?
|
|
|
|
|
What do you mean by "select a ... selected value"??
Are you talking about a ListView setup for multi-select and you want to iterate over the items selected by the user?
|
|
|
|
|
Has anyone ever managed to clear the MS Access (2003) sync list?
Under Tools > Replication > Synchronize Now...
I get the window to choose the location of my replica.
Now due to numerous attempts, my list has grown rather large, and I haven't found how to remove entries or how to clear it.
The correct entry is the second one, and this requires users to have to change their selection.
I've actually made a VBA button that uses a hard coded value to synchronize sans the dialogs.
There's gotta be a way around this.
(and no, I'm not willing to make a new database and import stuff.)
thanks in advance.
(i hope this is the most relevant message board)
Eric D. Georgiades
Networking Professional / Multimedia Developer
|
|
|
|
|
Eric Georgiades wrote: (i hope this is the most relevant message board)
You're actually looking for a site dedicated to Office. CP doesn't have an Office forum and does very little with it.
AFAICT, there's no way to clear that list. There's nothing stored in the Registry, nor any file in the users Windows profile, other than inside the Design Master database. So, basically, you can't clear this list without doing:
Eric Georgiades wrote: (and no, I'm not willing to make a new database and import stuff.)
|
|
|
|
|
Dave Kreskowiak wrote: AFAICT, there's no way to clear that list.
I was afraid so.
I always appreciate your expertize,
even though it's an office question
thanks again.
Eric D. Georgiades
Networking Professional / Multimedia Developer
|
|
|
|
|
Goal: I would like to be able to display "XXXX users are currently logged in" on a webpage in my web application. XXXX represents the number of users who are currently logged into the application.
In my application, each user has their own unique username and password combination. When a successful login occurs, a field called "UsrIsLoggedIn" is updated with a 1 for that user. UsrIsLoggedIn is a tinyint data type and will always contain data that is either a 1 or a 0. When a user clicks the "logout" button, the UsrIsLoggedIn changes from a 1 to a 0. However, if a user does not click the "logout" button and closes the browser to end their session, there is no way to know that they are logged out. I want to be able to create an administration page that shows who is currently logged into the application. Any ideas? Or is there a better way to accomplish this goal? Any thoughts would be appreciated! Thanks!
|
|
|
|
|
select count(*) from logins where UsrIsLoggedIn = 1
I'd store the time the logged in user last asked for a page, and then, when this time is over a certain amount, log them out.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Chrisitan,
Thanks for the reply.
You said "I'd store the time the logged in user last asked for a page, and then, when this time is over a certain amount, log them out.". I thought about this idea originally too; however, it would rarely be accurate. Regardless of whether or not I set the logout time to 20 minutes later, 4 hours later, or 1 day later - I could actually be updating their status as being logged out of the application when they are in fact logged into the application. Do you have any other ideas?
|
|
|
|
|
Mr Business Kid wrote: Regardless of whether or not I set the logout time to 20 minutes later, 4 hours later, or 1 day later - I could actually be updating their status as being logged out of the application when they are in fact logged into the application. Do you have any other ideas?
There's really no way around this. Your server-side code cannot know if the user is either just sitting there staring at a page, or if the user closed the browser. There is no event that's fired on the client-side that the browser is closing down. No event means no notification to the server.
This is just a fact of web life you have to put up with.
|
|
|
|
|
Well, the only other thing you can try is to embedd an AJAX call in all your pages so that it sends a message logging them out. This is also not going to work 100% of the time, which is why a timeout is a good idea.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
the following catches the user changing the page, leaving your website, closing down the browser. you fire one last call of (ajax or whatever) to log the user off. I didn't code for it but if the navigation came from the page then ignore the unload event, if it came from somewhere else, the event fires... not perfect but it works
<html>
<script language="javascript">
function LoadMe()
{
alert("hi")
}
function UnloadMe()
{
alert("Bye")
}
</script>
<body onload="LoadMe()" onunload="UnloadMe()">
<form action="test.htm">
hello
<a href="test.htm">me</a>
<a href="http://www.yahoo.com">yahoo</a>
</form>
</body>
</html>
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
<div class="ForumMod">modified on Monday, March 17, 2008 10:18 PM</div>
|
|
|
|
|
I created a dataTable which I am using to populate a combo box. When I select a student fromthe student combo box the lesson combo box is populated with info from the data table. When I select a student with the student combo box I get the following error.
Can you tell me why?
Here is the function that is giving me the error.
Public Function selectLesson() As DataTable
' declare data table
Dim dt As New DataTable()
Dim dr As DataRow
dt.Columns.Add(New DataColumn("lessonTime", GetType(String)))
dt.Columns.Add(New DataColumn("lessonID", GetType(String)))
For Each row As DataRow In dtLessTime.Rows
dr = dt.NewRow()
dr(0) = " " & arrWeekDays(Convert.ToInt32(row("less_day")) - 1) ' & " " & Convert.ToDateTime(row("less_time"))
dr(1) = row("less_id")
dt.Rows.Add(dr)
Next
Return dt
End Function
|
|
|
|
|
Well, the code that creates this new table, and adds rows to it, looks OK. The problem may be that the dtLessTime.Rows collection may be empty, or some other problem with it.
|
|
|
|
|
I'm sure this has been addressed, but I can't seem to find it. Sometimes when I open another window from a dropdown, the dropdown box items remain glued to the screen. The box just sits there in front of every other window, and never goes away. What am I doing wrong?
Thanks
|
|
|
|
|
cstrader232 wrote: Sometimes when I open another window from a dropdown, the dropdown box items remain glued to the screen. The box just sits there in front of every other window, and never goes away.
I can't duplicate the problem. Have you tried updating your video card drivers?
|
|
|
|
|
I am having trouble connecting to my pc using a mobile device. I created a tcplistener on my pc and am trying to put a tcpClient or socket on the device but am having trouble. I hope someone can help me.
This is the code I have for the device. I have tried this different ways depending on what search engine results I got. Here is my latest:
Dim tcpCli As New Sockets.TcpClient("lit3.local.local", 2048)
Dim ns As NetworkStream = tcpCli.GetStream()
Dim sw As New StreamWriter(ns)
sw.WriteLine("BUYER")
sw.Flush()
I also tried:
Dim sock As Socket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
Dim ipep As IPEndPoint = New IPEndPoint(IPAddress.Parse("194.268.150.142"), 2048)
sock.Connect(ipep)
Dim ns As NetworkStream = New NetworkStream(sock)
Dim sw As New StreamWriter(ns)
sw.WriteLine("BUYER")
sw.Flush()
I am trying to send a string to my computer so my application can test the string and do a certain method depending on the string.
Can someone help me?
Thank you.
|
|
|
|
|
Well, both examples you posted are missing things. The first doesn't connection to the target at all. The second connects, but does retrieve the underlying stream. So, you combine the two and you get something like this:
Dim tcpClient As New System.Net.Sockets.TcpClient()
tcpClient.Connect("127.0.0.1", 8000)
Dim networkStream As NetworkStream = tcpClient.GetStream()
If networkStream.CanWrite And networkStream.CanRead Then
Dim sendBytes() As Byte = Encoding.ASCII.GetBytes("Is anybody there")
networkStream.Write(sendBytes, 0, sendBytes.Length)
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
Dim returndata As String = Encoding.ASCII.GetString(bytes)
|
|
|
|
|
Thank you for helping me on this. But, I get an error on the second line of code: target machine actively refused it.
Let me show you how I have this set up so you can clearly see any problems.
Server - My PC on a network separate application of desktop where listener is
Code:
Dim desktop As SteidingerDesktop = New SteidingerDesktop
Dim localhostAddress As IPAddress = IPAddress.Loopback
Dim tcpList As New TcpListener(localhostAddress, 2048)
tcpList.Start()
Do
Dim tcpcli As TcpClient = tcpList.AcceptTcpClient
Dim ns As NetworkStream = tcpcli.GetStream
Dim sr As New StreamReader(ns)
Dim receivedData As String = sr.ReadLine()
Dim result As Boolean
If receivedData <> "" Then
'Test the received data to see which function to call
If receivedData = "BUYER" Then
result = desktop.getBuyers()
ElseIf receivedData = "SHIP" Then
result = desktop.updateShip()
ElseIf receivedData = "MOVE" Then
result = desktop.updateMove()
ElseIf receivedData = "PHYINV" Then
result = desktop.updatePhyInv()
End If
Try
' resultData = file.ReadAllText(fileName)
Catch ex As Exception
'send back result result = "ERROR"
End Try
'Send result
SendData(ns, result)
End If
sr.Close()
ns.Close()
tcpcli.Close()
If receivedData = "" Then Exit Do
Loop
tcpList.Stop()
Client - mobile device barcode scanner on wireless
Code:Your code.
Dim tcpClient As New System.Net.Sockets.TcpClient()
tcpClient.Connect("ipaddress of my desktop", 2048)
Dim networkStream As NetworkStream = tcpClient.GetStream()
If networkStream.CanWrite And networkStream.CanRead Then
Dim sendBytes() As Byte = Encoding.ASCII.GetBytes("Buyer")
networkStream.Write(sendBytes, 0, sendBytes.Length)
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
Dim returndata As String = Encoding.ASCII.GetString(bytes, 0, bytes.Length)
End If
Can you look at this code and tell me why I get the error? thank you.
|
|
|
|
|
Hey
I want to draw in a user control, but for some reason it doesn't work. The user control colors blue, but I can't see a yellow circle. Maybe it would be better to make a panel - user control, but I don't know how to do this.
<br />
Public Class cell<br />
Private Sub cell_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
<br />
'Set Background of cell (panel)<br />
pnlCell.BackColor = Color.Blue<br />
<br />
'Draw circle in cell (panel)<br />
DrawCircle(New Point(10, 10), 5)<br />
End Sub<br />
<br />
Private Sub DrawCircle(ByVal p As Point, ByVal radius As Integer)<br />
Dim gr As Graphics = pnlCell.CreateGraphics<br />
Dim rect As Rectangle = New Rectangle(p.X - radius, p.Y - radius, 2 * radius, 2 * radius)<br />
gr.FillEllipse(Brushes.Yellow, rect)<br />
End Sub<br />
End Class
|
|
|
|
|
Your drawing code should be in the Paint event of your UserControl, not called from form load.
|
|
|
|
|
N!ck wrote: Dim gr As Graphics = pnlCell.CreateGraphics
To expand on the previous reply - CreateGraphics is used to draw something that is temporary, it gets erased the moment the control redraws itself. After the control loads, it will become visible, and will redraw itself.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi,
I want to take snap shot current application which is running on the other machine.
How Can I go further?
Regards,
sjs4u
|
|
|
|
|