Have found a guiding on the net to deal with the following:
Dealing with serial port .Net object to forward the ReadLine to raise the event in the foreground tread without crash the AVM.
But cannot find source code examples how to do this.
Who know and want to share this?
Kind regards,
Peter Wokke
You're willing to build your own C# assembly? Because it requires .NET code.
A .NET Control is able to raise an event from a background thread in the UI thread. Code looks like this, in a class inheriting from Control. This code will raise the event from the foreground thread when already running there and switch to the foreground thread if required - in the ABL you put that Control on a Form (might be a very small Control):
protected void OnDataAvailable (EventArgs e) { if (this.InvokeRequired) this.BeginInvoke(new Action<EventArgs>(OnDataAvailable), new[] { e }); else this.DataAvailable(this, e); }
Mike,
Thank you kindly for your guiding.
I am working and a C# assembly to deal with the read options on the serial port.
Now I run on an error that multi-treating is not supported in ABL .Net.
Will work on this and see what happens.
Regards, Peter
Mike,
Thank you kindly for your guiding.
I am working and a C# assembly to deal with the read options on the serial port.
Now I run on an error that multi-treating is not supported in ABL .Net.
Will work on this and see what happens.
Regards, Peter
I'm using mscomm32.ocx, on non .NET frame, but it allows me to send some code on the port, and then wait for the weight scale to answer...(even installed on syswow64 dir of a win64).
Isn't this something that can help you?
Hello Octavio,
The mscomm32.ocx is an 32bit DLL that I cannot load in a 64bit Progress AppBuilder session.
Now I have to find out hou to create an ABL .Net class inheriting from control.
Other option id to load the kernel32 in C# and access the comm port based on this kernel32.
King regards,
Peter
Hi Peter,
Totally beside your original question but I try to avoid serial communication in OpenEdge completely.
When confronted with a serial device we try to hook it up to a Moxa serial device server that turns serial into socket communication.
PS: I have no shares in Moxa ;-)
Peter.. you can use mscomm32 in win64....
put the ocx in sysWOW64 directory and register (regsvr32) from there....
and that's it...
You can use 32 bit DLL's or Active X's in 32 bit apps on Windows 64 bit yes.
But you can't use 32 bit DLL's or Active X's in 64 bit apps. So your trick won't work for 64 bit versions of OpenEdge.
And for maintenace i try not to open in uib, just the editor.... (matter of fact, 15 years ago I build that interfase in V9) and only once I had to add field to show activity...
trying to post....
sorry.
missed wrx
please rename to mfq-40.wrx
You will need to Invoke the event on the main thread in your c# DLL.
E.g
//Declare a dispatcher
private Dispatcher _uiDispatcher; // This will be the UI Dispatcher which runs on the main the
// Get the UI Thread Dispatcher important as we need to dispatch this event on the main thread
_uiDispatcher = Dispatcher.CurrentDispatcher;
When it comes to raising the event.... and you are not on the main thread invoke...
// Are we on the GUI thread?
if (Dispatcher.CurrentDispatcher != _uiDispatcher)
{
_uiDispatcher.Invoke(OnCSSConversationAdded, this, myConversationAddedEventArgs);
}
else
{
OnCSSConversationAdded(this, myConversationAddedEventArgs);
}