473,382 Members | 1,247 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Process space problem in C#.NET

MR
I have two C#.Net projects, both of which create instances of the same C#
class from a separate assembly; the class creates its own thread.

When either project is run alone, it works correctly. However, when they
are run simultaneously, I get a threading error (from
System.Threading.ThreadHelper.ThreadStart_Context) in the project that
starts last.

Don't C# .Net programs run in their own process spaces? Does the fact that
they both instantiate the same class from the same assembly mean that the
process space is shared?

Thanks for any ideas on this.
Jan 13 '08 #1
4 2963
MR <eb*@noemailspam.comwrote:
I have two C#.Net projects, both of which create instances of the same C#
class from a separate assembly; the class creates its own thread.

When either project is run alone, it works correctly. However, when they
are run simultaneously, I get a threading error (from
System.Threading.ThreadHelper.ThreadStart_Context) in the project that
starts last.

Don't C# .Net programs run in their own process spaces? Does the fact that
they both instantiate the same class from the same assembly mean that the
process space is shared?

Thanks for any ideas on this.
Yes, they'll be in their own process spaces - but what's the error
you're getting?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Jan 13 '08 #2
MR
The final error is:

System.IO.EndOfStreamException was unhandled
Message="Unable to read beyond the end of the stream."

The stack trace is:

Source="mscorlib"
StackTrace:
at System.IO.__Error.EndOfFile()
at [locations in my program]
at System.Threading.ThreadHelper.ThreadStart_Context( Object state)
at System.Threading.ExecutionContext.Run(ExecutionCon text
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

Both processes create a thread to read from the same socket (the socket is
from the same source, a third-party control). The socket is created using
the TpClient class in System.Net.Sockets.

The error may be due to the fact that they both read from the same source,
and the thread in the first instance has read all the data before the thread
in the second instance can read it. But I've used multiple instances of an
ActiveX control to do the same thing from the same control, without any
errors.

If you need any more information, please let me know, and thanks for any
help you can give me.
"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP*********************@msnews.microsoft.com. ..
MR <eb*@noemailspam.comwrote:
>I have two C#.Net projects, both of which create instances of the same C#
class from a separate assembly; the class creates its own thread.

When either project is run alone, it works correctly. However, when they
are run simultaneously, I get a threading error (from
System.Threading.ThreadHelper.ThreadStart_Context ) in the project that
starts last.

Don't C# .Net programs run in their own process spaces? Does the fact
that
they both instantiate the same class from the same assembly mean that the
process space is shared?

Thanks for any ideas on this.

Yes, they'll be in their own process spaces - but what's the error
you're getting?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk


Jan 14 '08 #3
MR <eb*@noemailspam.comwrote:

<snip>
Both processes create a thread to read from the same socket (the socket is
from the same source, a third-party control). The socket is created using
the TpClient class in System.Net.Sockets.
Right, I can see how that would be a problem. Sockets aren't meant to
be read from multiple processes.
The error may be due to the fact that they both read from the same source,
and the thread in the first instance has read all the data before the thread
in the second instance can read it. But I've used multiple instances of an
ActiveX control to do the same thing from the same control, without any
errors.

If you need any more information, please let me know, and thanks for any
help you can give me.
It sounds like you really need to remove the idea of reading data from
the same socket from different processes. I just can't see that
working.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Jan 14 '08 #4
MR
Thanks very much for your reply. The had separated the ActiveX control into
two processes because I had what appeared to be thread contention, and that
solved the problem. Since I didn't write the ActiveX control (it was
supplied by a third party), I had no other way handle the problem.

However, the socket runs on its own thread. In this case, I will just
combine the functions into the same process, as
you suggest.

Thanks again.
"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP*********************@msnews.microsoft.com. ..
MR <eb*@noemailspam.comwrote:

<snip>
>Both processes create a thread to read from the same socket (the socket
is
from the same source, a third-party control). The socket is created
using
the TpClient class in System.Net.Sockets.

Right, I can see how that would be a problem. Sockets aren't meant to
be read from multiple processes.
>The error may be due to the fact that they both read from the same
source,
and the thread in the first instance has read all the data before the
thread
in the second instance can read it. But I've used multiple instances of
an
ActiveX control to do the same thing from the same control, without any
errors.

If you need any more information, please let me know, and thanks for any
help you can give me.

It sounds like you really need to remove the idea of reading data from
the same socket from different processes. I just can't see that
working.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk


Jan 14 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: News | last post by:
All, If I have a series of php files under C:\INETPUB\PROJECT with quite a few SUBDIRECTORIES also (i.e. a standard PHPNuke install), is there a way to have phpCB "batch" process all of the files...
77
by: Charles Law | last post by:
Hi guys I have a time critical process, running on a worker thread. By "time critical", I mean that certain parts of the process must be completed in a specific time frame. The time when the...
2
by: Aravind | last post by:
Hi , This is a Windows form application which interacts with the unmanaged C++ codes . In unmanaged c++ code we allocate around 130MB on the heap for annalysing high resolution images . Earlier...
7
by: Samantha | last post by:
Hello , I am developping a program for Win98 plateform, and I am stucking with a problem, hope you can help me. I have a program running 2 process : - One process running the Xcopy.exe -...
22
by: nd02tsk | last post by:
Hello! I have a couple of final ( I hope, for your sake ) questions regarding PostgreSQL. I understand PostgreSQL uses processes rather than threads. I found this statement in the archives: ...
22
by: Zen | last post by:
Hi, My production machine has 2G of memory, when aspnet_wp.exe goes up to about ~1.2G of memory usage, I start get out-of-memory exception. Other processes don't use as much memory and I added...
8
by: Henrik | last post by:
Hi Is there any way to see what the System process is doing? We have developed an application running at a production site to measure and optimize the production. The application needs to be...
28
by: Jon Davis | last post by:
We're looking at running a memory-intensive process for a web site as a Windows service in isolation of IIS because IIS refuses to consume all of the available physical RAM. Considering remoting to...
4
by: Daniel | last post by:
is there some per-process-limit on memory in .net processes? is there any way to increase it? i keep getting System.OutOfMemoryException when my box has 8 gigs of unused memory.
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
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,...
0
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$) { } ...
0
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...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.