Hi,
I have a class whose constructor accepts a Socket as an argument. The
constructor then makes a call to Socket.BeginRec eive(). The callback
delegate passed to BeginReceive() is a method of my class. There is a slight
chance that the callback delegate will be called from the I/O thread pool
BEFORE my constructor completes. Is calling this delegate before the
constructor finishes a problem?
In C++, this type of arrangement was a problem as I recall. In C#, it
doesn't seem like it SHOULD be a problem. After all, I can call private
methods from my constructor so why shouldn't some external party be able to
call them in the midst of construction as well? In any case, I just wanted
to double-check!
Granny 2 1902
To side-step this issue and possible others, you could (of course) create
..Send() public method or .Connect() and use that after construction. You
can still set the socket var in your constructor and/or property of the
class.
--wjs
"Grandma Wilkerson" <tu**@bottlenec k.scalability.c rash.dum> wrote in message
news:OW******** ******@TK2MSFTN GP12.phx.gbl... Hi,
I have a class whose constructor accepts a Socket as an argument. The constructor then makes a call to Socket.BeginRec eive(). The callback delegate passed to BeginReceive() is a method of my class. There is a
slight chance that the callback delegate will be called from the I/O thread pool BEFORE my constructor completes. Is calling this delegate before the constructor finishes a problem?
In C++, this type of arrangement was a problem as I recall. In C#, it doesn't seem like it SHOULD be a problem. After all, I can call private methods from my constructor so why shouldn't some external party be able
to call them in the midst of construction as well? In any case, I just wanted to double-check!
Granny
Grandma Wilkerson <tu**@bottlenec k.scalability.c rash.dum> wrote: I have a class whose constructor accepts a Socket as an argument. The constructor then makes a call to Socket.BeginRec eive(). The callback delegate passed to BeginReceive() is a method of my class. There is a slight chance that the callback delegate will be called from the I/O thread pool BEFORE my constructor completes. Is calling this delegate before the constructor finishes a problem?
Well, it'll be a potential problem if the delegate relies on
information which is set up after Socket.BeginRec eive() is called, but
I don't think it's fundamentally a problem. Probably worth documenting
very clearly though, for maintenance purposes.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Christian Dieterich |
last post by:
Hi,
I need to create many instances of a class D that inherits from a class
B. Since the constructor of B is expensive I'd like to execute it only
if it's really unavoidable. Below is an example and two workarounds,
but I feel they are not really good solutions. Does somebody have any
ideas how to inherit the data attributes and the methods of a class
without calling it's constructor over and over again?
Thank,
|
by: Jerry Krinock |
last post by:
I've written the following demo to help me understand a problem I'm having
in a larger program. The "main" function constructs a Foo object, and then
later "reconstructs" it by calling the constructor again. In my larger
program, I find that the member variables don't get re-initialized when
"reconstructed". I don't have that problem in this demo, but the second
time the constructor is called, its "this" points to a different location.
...
|
by: Grandma Wilkerson |
last post by:
Hi,
I have a class whose constructor accepts a Socket as an argument. The
constructor then makes a call to Socket.BeginReceive(). The callback
delegate passed to BeginReceive() is a method of my class. There is a slight
chance that the callback delegate will be called from the I/O thread pool
BEFORE my constructor completes. Is calling this delegate before the
constructor finishes a problem?
In C++, this type of arrangement was a...
|
by: Greg Bacchus |
last post by:
I have a base class with a method that is to be called in the constructor of
the inheritting classes. Is there any way of determining, say, the Type of
the class that is calling it.
e.g.
class A
{
public A()
{
|
by: Pete Davis |
last post by:
I know I can use reflection to call internal, protected, and private methods
in a class, but I need to instantiate an object that is public but has an
internal constructor (The CurrencyManager class).
Is there a way to do this with reflection?
I'm so mad at MS about the CurrencyManager design it makes me want to
scream. It's been causing me headaches for months.
All of this would be easily fixable if I could create my own...
| |
by: torbs |
last post by:
Hi
I have a a function with several methods. For simplicity it looks a bit
like this:
super.prototype.aProperty="HELLO";
super.prototype.returnValue = function () {
return 2;
|
by: rickeringill |
last post by:
Hi comp.lang.javascript,
I'm throwing this in for discussion. First up I don't claim to be any
sort of authority on the ecmascript language spec - in fact I'm a
relative newb to these more esoteric uses (abuses?) of the language.
I've been working from the oft quoted resource
http://www.crockford.com/javascript/private.html. During my first
serious attempt at using the knowledge acquired from this page, I ran
up against the problem...
|
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= |
last post by:
I have a C# logging assembly with a static constructor and methods that is
called from another C# Assembly that is used as a COM interface for a VB6
Application. Ideally I need to build a file name based on the name of the
VB6 application. A second choice would be a file name based on the # COM
interface assembly. I have tried calling Assembly.GetCallingAssembly() but
this fails when I use the VB6 client. Is there a way to get this...
|
by: bizt |
last post by:
Hi,
Below I have a simple object / function thing (still getting head
round these) declaration:
function MyObject() {
this.alertMe = function() {
alert('hello');
};
this.alertMeAgain() {
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |