|
I am writing a program that accesses a CICS system using a socket. The problem I am having is that the server is slow and sends either a maximum of 393 bytes total (size of record) or a Chr(13) showing that the output is complete.
My question is that whether it is better to read byte for byte from the server (since it is slow) or set the receive window size in the tcpclient. The second solution has a limitation since I am waiting for a particular character in the output stream to show that my output has ended.
Thanks,
|
|
|
|
|
There is an Example in the MSDN help on receiving Data from a Socket. However, it uses the TCPClient Class instead of Socket, I am sure you can modify this. Do a search on "Chat" and it should find an example of a Chat application. In that example, it will show how to receive data Asynchronously.
|
|
|
|
|
I have an object that fires an event and a form that handles that event. When handling the event i show a new form but the new form hangs. It gets "Loaded", "VisibleChanged" and "Activated" events and hangs. I am attaching vb code as an example.
Please see and if you can figure out why it is so i will really appreciate if you tell me.
Thanks in advance!!!!
P.S. as I understand its a bug - the form must show without problems!!!
here is the sample code of the error in vb.net ))
'Class EventRaiser raises SomeEvent 3 seconds after it is loaded.
'EventHandlerForm handles that event and shows modeless form.
'Normally the new form must have no problems but actually it
'receives "Load", "VisibleChanged" and "Activated" events and hangs.
'Raises event "SomeEvent" 3 seconds after it is created.
Public Class EventRaiser
Public Event SomeEvent()
Private WithEvents myTimer As New System.Timers.Timer()
Sub New()
myTimer.Interval = 3000
myTimer.Start()
End Sub
Private Sub mytimer_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) Handles myTimer.Elapsed
RaiseEvent SomeEvent()
myTimer.Enabled = False
End Sub
End Class
Public Class EventHandlerForm
Inherits System.Windows.Forms.Form
'EventRaiser raises SomeEvent 3 seconds after it is created.
Private WithEvents myEventRaiser As New EventRaiser()
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Label1 As System.Windows.Forms.Label
<system.diagnostics.debuggerstepthrough()> Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label()
Me.SuspendLayout()
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(16, 16)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(320, 32)
Me.Label1.TabIndex = 0
Me.Label1.Text = "New Form is shown after 3 seconds. After it is show it hangs."
'
'EventHandlerForm
'
Me.AutoScale = False
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(344, 53)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label1})
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
'In the myEventRaiser.SomeEvent handler a new form is shown modeless.
'New form receives "Load", "VisibleChanged" and "Activated" events
'and hangs
Private Sub EventRaiser_SomeEvent() Handles myEventRaiser.SomeEvent
Dim ff As New Form()
ff.Show()
End Sub
End Class
|
|
|
|
|
There is something about creating the new form inside that event handler. Creating the few form inside the handler for a button works perfectly, but not inside the myEventRaiser.SomeEvent handler for some reason.
RageInTheMachine9532
|
|
|
|
|
You "Dim"-ed the Form variable inside the Event Handler. Remember that anytime a Routine goes out of Scope, the Variables in that Routine also get destroyed. This could be causing the problem. Dim the Form variable outside of the Event Handler routine.
Hope that helps!
|
|
|
|
|
I've tried that already. But in the example i use System.Timers.Timer class.
If i use the System.Windows.Forms.Timer then it works ok. I want to understand whats the difference in the events???
|
|
|
|
|
Ahh, Ok, then this might be because the System.Timers work on a separate Thread. The Windows.Forms.Timer works because it's on the same thread as the UI.
In your Code you need to say "Me.Invoke(..." in order to get your new Form loaded into the MAIN UI Thread. Other wise, it's loading your new Form into a separate Thread in which you cannot control this new Form. Read up on Multithreading...a good example is the Chat application in the MSDN.
|
|
|
|
|
I get it now!! ))
Thanks a lot!!!
|
|
|
|
|
I couldn't seem to find the answer from whatever documents I have right now... In C/C++ we have "default parameters" for functions, int Func(int nPara1, int nPara2 = 0); , but how do we achieve this in VB? Thanks a lot.
|
|
|
|
|
|
Thanks for your reply, I forgot to mention that I was using VBScript(ASP application) so the "Optional" keyword is not supported Is there anyway I can do that in VBScript? Thank you.
|
|
|
|
|
Option parameters are not supported at all. I haven't tried it, but since all variables in VBScript are of type Variant, you might look into passing an array of values to your function. This could be used to simulate optional arguments, but your function will have to be written to parse up the array and you can't pass parameters by reference at all.
RageInTheMachine9532
|
|
|
|
|
And C# is missing this functionality (unless you like to have 10's of overloads).
This is one of the main reason I am still mainly developing in VB.NET. Has everything C# has (almost) plus some extras... I also feel the IDE is much more responsive with VB.NET...
My 2¢.
Carl
|
|
|
|
|
I want to know how to capture the desktop screen of the client's machine from the server machine.......the screen must sending over using winsock.........
|
|
|
|
|
|
can u more specify........any code about remotely monitor
|
|
|
|
|
|
but that is a software, how can i put it or integrate into vb program........
|
|
|
|
|
The bottom line is that it is not easy. You'll need a some type of server service running on the machine you want to monitor. Then you'll need a client on the machine doing the monitoring.
The previous guy is right with VNC. It's just about the best open source remote control software I've found. Comes with source code too.
RageInTheMachine9532
|
|
|
|
|
I am writing an app that will reside on a W2k server. The app will be started from a shortcut on the users desktop. The app will allows users to construct a operating system level command with parameters and excute the command on the server. The command returns monitoring info (for those of you familiar with GIS and ArcSDE, it's the sdemon command, which is usually executed from the command line). I can do that part now by using the Shell function. The info returned is briefly displayed in a dos-like window which automatically closes when all info is displayed.
I want to redirect the returned info (text) to the Windows Notepad app where the user can edit, save, etc. I have also tried using the functionality provided by System.Diagnostics.ProcessStartInfo but have so far been unsuccessful.
Any ideas would be very helpful and much appreciated.
|
|
|
|
|
Kan we use P/Invoke in VB.NET to call unmanaged DLLs, including those that implement the Win32 API.
I am looking for an exaple doing this.
|
|
|
|
|
Hi, how to create ListView behave like TreeNode
TQ
|
|
|
|
|
What exactly do you want? A ListView cannot "behave like a TreeNode".
|
|
|
|
|
but i saw a sample in C# in this web site?
|
|
|
|
|