Hi,
I wrote a C# program that is calling C++ legacy code to open a serial port
(using CreateFile (comPort,
GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,FI LE_FLAG_OVERLAPPED,NULL))
..
So far, it works.
Now, at startup, I start 4 C# threads.
These threads are opening Com ports #2, #3, #4 and #5.
Sometimes, these 4 Com ports are opened successfully but, most of the time,
1 Com port opening failed.
The GetLastError returns 5 (access denied).
So, my question is :
Is it safe to call 4 CreateFile (for different Com ports of course) in
parallel thread at the same time ?
Thanks in advance for your help,
Droopy. 5 6879
Droopy <dr**************@hotmail.com> wrote in
news:Xn**********************************@195.129. 110.71: Hi,
I wrote a C# program that is calling C++ legacy code to open a serial port (using CreateFile (comPort, GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,FI LE_FLAG_OVERLAPPED,NU LL)) . So far, it works. Now, at startup, I start 4 C# threads. These threads are opening Com ports #2, #3, #4 and #5. Sometimes, these 4 Com ports are opened successfully but, most of the time, 1 Com port opening failed. The GetLastError returns 5 (access denied).
So, my question is :
Is it safe to call 4 CreateFile (for different Com ports of course) in parallel thread at the same time ?
Thanks in advance for your help,
Droopy.
Who can help me ?
Droopy <dr**************@hotmail.com> wrote in
news:Xn**********************************@195.129. 110.71: Hi,
I wrote a C# program that is calling C++ legacy code to open a serial port (using CreateFile (comPort, GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,FI LE_FLAG_OVERLAPPED,NU LL)) . So far, it works. Now, at startup, I start 4 C# threads. These threads are opening Com ports #2, #3, #4 and #5. Sometimes, these 4 Com ports are opened successfully but, most of the time, 1 Com port opening failed. The GetLastError returns 5 (access denied).
So, my question is :
Is it safe to call 4 CreateFile (for different Com ports of course) in parallel thread at the same time ?
Thanks in advance for your help,
Droopy.
Who can help me ?
Yes it is. The "Access denied" error code has IMO nothing to do with the
number of threads, are you sure this error is returned by the CreateFile
call?
Willy.
"Droopy" <dr**************@hotmail.com> wrote in message
news:Xn**********************************@195.129. 110.71... Hi,
I wrote a C# program that is calling C++ legacy code to open a serial port (using CreateFile (comPort, GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,FI LE_FLAG_OVERLAPPED,NULL)) . So far, it works. Now, at startup, I start 4 C# threads. These threads are opening Com ports #2, #3, #4 and #5. Sometimes, these 4 Com ports are opened successfully but, most of the time, 1 Com port opening failed. The GetLastError returns 5 (access denied).
So, my question is :
Is it safe to call 4 CreateFile (for different Com ports of course) in parallel thread at the same time ?
Thanks in advance for your help,
Droopy.
Yes.
To be more precise, CreateFile returns INVALID_HANDLE_VALUE and
GetLastError () returns 5 (Access Denied)
Sorry for this late answer. Yes it is. The "Access denied" error code has IMO nothing to do with the number of threads, are you sure this error is returned by the CreateFile call?
Willy.
"Droopy" <dr**************@hotmail.com> wrote in message news:Xn**********************************@195.129. 110.71... Hi,
I wrote a C# program that is calling C++ legacy code to open a serial port (using CreateFile (comPort, GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,FI LE_FLAG_OVERLAPPED,N ULL)) . So far, it works. Now, at startup, I start 4 C# threads. These threads are opening Com ports #2, #3, #4 and #5. Sometimes, these 4 Com ports are opened successfully but, most of the time, 1 Com port opening failed. The GetLastError returns 5 (access denied).
So, my question is :
Is it safe to call 4 CreateFile (for different Com ports of course) in parallel thread at the same time ?
Thanks in advance for your help,
Droopy.
Who can help me ?
Have I to start it sequentially or add any timeout between thread
starting ?
Droopy <dr**************@hotmail.com> wrote in
news:Xn**********************************@195.129. 110.71: Yes. To be more precise, CreateFile returns INVALID_HANDLE_VALUE and GetLastError () returns 5 (Access Denied)
Sorry for this late answer.
Yes it is. The "Access denied" error code has IMO nothing to do with the number of threads, are you sure this error is returned by the CreateFile call?
Willy.
"Droopy" <dr**************@hotmail.com> wrote in message news:Xn**********************************@195.129. 110.71... Hi,
I wrote a C# program that is calling C++ legacy code to open a serial port (using CreateFile (comPort,
GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,FI LE_FLAG_OVERLAPPED,N ULL)) . So far, it works. Now, at startup, I start 4 C# threads. These threads are opening Com ports #2, #3, #4 and #5. Sometimes, these 4 Com ports are opened successfully but, most of the time, 1 Com port opening failed. The GetLastError returns 5 (access denied).
So, my question is :
Is it safe to call 4 CreateFile (for different Com ports of course) in parallel thread at the same time ?
Thanks in advance for your help,
Droopy.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jon Skeet [C# MVP] |
last post by:
Please excuse the cross-post - I'm pretty sure I've had interest in the
article on all the groups this is posted to.
I've finally managed to finish my article on multi-threading - at least
for...
|
by: Droopy |
last post by:
Hi,
I wrote a C# program that is calling C++ legacy code to open a serial port
(using CreateFile (comPort,
GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,FILE_FLAG_OVERLAPPED,NULL))
..
So...
|
by: shussai2 |
last post by:
Hi,
I am trying to access Serial Port in XP. I am using Dev-C++ IDE that
uses Mingw as a compiler. I just want to know how I can open up serial
port on COM1 and write some data. I have searched...
|
by: bmearns |
last post by:
Is it possible to specify which port to use as the outbound port on a
connection? I have the IP address and port number for the computer I'm
trying to connect to (not listening for), but it's...
|
by: abid gee |
last post by:
Please give a kind look on my question. and please comments.
I am Using C# as development tool of Dot Net 2.0.
I wrote a function read_data() that read data from Serial Port
continuously.Till...
|
by: ammoos |
last post by:
hi friends
pls help me.. i got an assignment which i feel very difficult to me.. i dont have more knowledge about multi-threading in .net...
the assignment details is below.... pls help me... i...
|
by: BruceWho |
last post by:
I downloaded boost1.35.0 and built it with following command:
bjam --toolset=msvc-7.1 --variant=release --threading=multi --
link=shared --with-system stage
and it failed to compile, error...
|
by: Andrew MacIntyre |
last post by:
Tony May wrote:
The DLL that's actually being imported by your script is not a Python
extension module, as the modules initialisation function can't be found.
Use the -v option on the Python...
|
by: Praki |
last post by:
Greetings All,
i think this is the right group to post this question.
i am working on client server model. in this model the client is
sending request in thousands in number. for example per...
|
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,...
|
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$) {
}
...
|
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...
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |