|
Seriously, I have been fooling around with this code for a week or so and I always end up back to sqaure 1. Can anyone see any flaws in the theoretical setup below?
* I am using sockets (CLIENT/SERVER)
* I use Async code for the BeginAccept and EndAccept on the socket (SERVER)
* I use Async reading for the messages coming in (CLIENT/SERVER)
* Using a single thread to send messages on the socket which utilizes an ArrayList of messages, clones the arraylist, does a foreach then writes each message then removes the message from the original arraylist[not the cloned] (CLIENT/SERVER)
A big problem I am having is that messages will come in like:
MESSAGE:blah:connect
MESSAGE:blah:messageMESSAGE:blah:somethingMESSAGE:blah:networks blow
And obviously I am expecting the messages to come in one at a time. I assumed that if I wrote them synchronously then the async receiving should work the way I intend. Is there a problem with this? Any help or guidance would certainly be appreciated.
|
|
|
|
|
I believe that you are running into a feature of the system. When your software takes longer to read the communications from the socket, the messages will pile up. At the next read, you can then retrieve (with one call) all the messages which have been sent.
So, your network protocol needs some method of delineating between the end of one message and the beginning of another. Once you have that arranged, you ought to be free of this problem.
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
Hello All,
I am running an external Process like Setup.exe from my program in C# and if the installation of Setup.exe is successful I need to update and XML document.
I am able to achieve the above part, but the real problem starts when the installation of Setup.exe fails or is cancelled by the user. If the installation is not successful, I should exit the application but my problem is that XML document gets updated. Since Setup.exe is an external Process, I have no idea how to check whether installation is cancelled or has failed.
I tried checking the Process.ExitCode but it is always ZERO whether the user is cancelling it or installation is successful.
Please anyone advice me on how to proceed.
Thanks in advance
Looney
|
|
|
|
|
Are there any registry keys that are created in the setup process, that you could check for ? Any files that must go to a specific path ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I have to first check whether there is a new Setup.exe and if found I have to call the Setup.exe.
Whenever the Setup.exe is installed successfully, registry keys will be created and also some files are copied to specific path because of Setup.exe.
Thanks in advance
Looney
|
|
|
|
|
Easy then. Check the registry keys, if they exist, setup was successful.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
But I have to run Setup.exe everytime when there is a new Setup.exe.
For example, Setup.exe is successful on the first run and required files are copied to a folder. After a week suppose there is new Setup.exe available. I will try to launch the new Setup.exe. At this moment I have to stop XML from saving if the user cancel's the Setup.exe installation or installation fails.
So how to check for registry at this point( that is after first run of Setup).
Thanks a lot
Looney
|
|
|
|
|
OK, I was asking if the setup creates something every time. Well, I assume then that your setup is actually updating a program ? So you know the install directory ? Make sure the setup always updates one particular file, then check the date it was last changed, that will tell you if it succeeded.
Or you could create a key which you delete every time, so it gets created solely to flag success in running setup. Or a key to store a version number, and you can check if it changes.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hello Graus,
I checked the install directory and everytime the installation is successful, its updating a ".ver" file. And if the installation fails, its not updating the ".ver" file. I can check whether the file is modified and if modified, I can update the XML.
I appreciate your quick help. You saved lot of my time.
Thanks a billion
Looney
|
|
|
|
|
No worries, glad to help.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hello All,
I am a beginner to .NET. I have a few icons in some directories and I want to add them to the nodes of Tree View dynamically but I have no idea. I went thru some message boards and also MSDN. Every where images are being added at design time.
Please help me. I am scratching my head since one day for this simple thing .
Thanks in advance
Looney
|
|
|
|
|
hi,
you can get help from here:
http://www.codeproject.com/cs/miscctrl/foldertreeview.asp
regards,
pubudu.
|
|
|
|
|
Well you have to follow some steps first. Create the node and then add the needed parameters
TreeNode tnNew;
TreeView oTv;
tnNew = oTv.Nodes.Add("Text to appear in the node ");
tnNew.Tag = "Tag of the node - it's ID";
tnNew.ImageIndex = 0; // Index of the selected image
tnNew.SelectedImageIndex = tnNew.ImageIndex;
|
|
|
|
|
Hello,
But I want to specify path for picking the images. Not by specifying the index.
Thanks
Looney
|
|
|
|
|
No way.
The way the TreeView works _is_ that you have the node icons in an imagelist and _only_ reference them by index.
Of course, you can add images to the imagelist at runtime and then set the new index, but you can't do it directly.
Regards,
mav
|
|
|
|
|
Hey!
I have a log program that logs all data from serial port in a textbox. This works good. But I’m not sure how it will react if it adds data to the textbox for days with out removing any data. Maybe textbox will be to slow especially with word-wrap?
To remove rows from a textbox is not too good, probably the textbox will redraw a couple of times witch I don’t have performance to.
If I use BeginUpdate and EndUpdate on a listbox maybe it could be faster? And if it is a listbox, then I can simply let there only be 400 rows or something like that.
I have tested RichTextBox, and just over some min the performance meter is going up, the text box is holding a stable level.
BestRegards
SnowJim
|
|
|
|
|
I wrote a similar application and used Listbox because I needed the data formatted like a grid. I did run into trouble with slow performance when I had about 10,000 lines (my app logged about 800,000 lines). So what I did was to limit the number of lines displayed to 1000 and when it reached 1000 I removed a line from top and added new line to bottom; however, the entire set of data was still being saved in memory using MemFile (C++). That is my input about listboxes. I haven't experienced with too many lines using textboxes; however, note that textboxes have a "Lines" property which holds an array of all lines in the textbox so I imagine you could remove lines from it if necessary.
|
|
|
|
|
Saving very long texts in a TextBox or a ListBox _only_ isn't a very good idea IMO.
If I had to do it, I'd show the last n entries (n=100 perhaps, configurable) in a ListBox and when more entries are added I'd remove the ones at the beginning of the list.
But I'd also log the data to a file, otherwise - apart from possible performance problems - all your log data is lost when the app ends (unexpectedly).
Regards,
mav
|
|
|
|
|
Hey!
I have a textbox that logs searten events, this text box will be filled over days and maybe weeks. The data flow in to this textbox can be fast.
The question is now: Will this result in memory overflow if no data is removed from the textbox? Or handles .NET this?
Best Regards
SnowJim
|
|
|
|
|
I believe a textbox has a maximum size. Certainly, you may want to set a maximum size, and trim from the string until it fits that size. If you want a full log, you should do it to disk, where it can be written and forgotten about.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Yes it is written to disk, but there most be a visible log there you can see the current dataflow.
textbox have e a maximum size, but what happens when it is full? will it remove from the begining or will it result in a memory overflow or somthing??
Best Regards
SnowJim
|
|
|
|
|
Like I said, set a maximum size, and keep removing text from the oldest record on, so it doesn't get out of control. As to your question, the obvious thing is to try it and see. You can write a loop that just keeps adding text to a textbox, can't you ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hello there!!!
How can make the mouse move by it self... Question 1
How can I make the mouse click by it self... in any place of the screen out side of the application... Question 2
well if any one knows
thanks
Mateus
|
|
|
|
|
Solution I can think of involves timer and P-Invoke SetCursorPos API[^].
Is there managed solution?
oakcool wrote:
How can I make the mouse click by it self... in any place of the screen out side of the application... Question 2
Unmanaged:
P-Invoke GetDesktopWindow[^] to get handle to desktop... then again P-invoke SendMessage[^] and pass it desktop handle. See details of API on MSDN or google or whatever.
Hope it helps.
David
Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy
|
|
|
|
|
dnh wrote:
Is there managed solution?
Yes there is. The System.Windows.Forms.Cursor.Position property gets or sets the cursor's position in screen coordinates.
www.troschuetz.de
|
|
|
|