|
I have search the CP site, and Google of course, but still haven't found what I am looking for.
Can you guys give me some links to articles/pages with information on using C# to do Binary Network Streams with C# asyncronously with multiple clients?
I am looking to make a program that sends different types of data back and forth between clients and server. I did get it to work with Remoting, but it gets slow with a bunch of clients. I would like to learn about binary streams anyway and this is a side project that doesn't need done right away. Also, I did get the binary network stream type of connection to work with one client, with only one send/recieve, but then it fails.
I think I might just be using the wrong keywords in my searches, if you know any I should try, send them my way as well.
Anyway, thanks for any and all help, and thank you for your time, I appriciate it.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
System.Net.Sockets.NetworkStream?
|
|
|
|
|
In the code I am working with i have a class called
RecordHistoryService<x,y>
X, and Y are unknown at design time and known at runtime
i need to instantiate RecordHistoryService<x,y>, is there any way to do it?
I have this, but it doesnt compile:
i.e.
Type _rhType = Type.GetType(rhType);
Type _entityType = Type.GetType(entityType);
RecordHistoryService<_rhType, _entityType> recordHistory;
thx for your help
|
|
|
|
|
Look into reflection.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
Is that the only way to do this?
I know that reflection is rather expensive.
|
|
|
|
|
It is the only way I can think of doing it. It is kind of expensive but not too horrible, one alternative(and I say that for lack of better word) is to make a bunch of methods that are specific to the type being passed, although I would NEVER do this, it is horrible practice.
My suggestion is reflection, although kind of expensive, it won't be bad unless doing this many times very fast.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
If the types are not totally random, you could use some kind of factory method to instantiate it...if totally random, I think the easiest way is to use reflection, or something like this article
Intelligence is almost useless for those who have nothing else!
Email: caiokf@gmail.com
|
|
|
|
|
You'd be looking at Type.MakeGenericType(...) off the top of my head.
|
|
|
|
|
I need a way to detect if my application is running in a TS/RDP session rather than right in front of the computer. I understand that Process.SessionID will be non-zero for a TS/RDP session. However, I just tested in Vista and it was a '1'. Does anyone know of a way to do this that will work in XP and Vista?
|
|
|
|
|
John Sposato wrote: Does anyone know of a way to do this that will work in XP and Vista?
I dont know either, but you can and should test it!
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - coming soon ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
I have a sql query and its return integer value.
sql = "...."
cmd.CommandText = sql;
ERROR: int id = (int)cmd.ExecuteScalar();
CORRECT: int id = Convert.ToInt32(cmd.ExecuteScalar());
Why can i get error when do casting between object type to integer data type?
|
|
|
|
|
Could it be that your query is returning null? You haven't said what error message you're getting!
If so, a null object can't be explicitly cast to an int [You could use a nullable int: (int?) ]. Convert.ToInt32(object) however returns zero if object is null.
If it's not the above, post the error message you're getting.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Most likely the first column of the first row in result is not an int (but for example DbType.Decimal etc).
If you get InvalidCastException, the exception along with the stack should show you what you are actually trying to cast to int.
The need to optimize rises from a bad design
|
|
|
|
|
Yes, DaveyM69's right, it's possible that your cmd.ExecuteScalar() returns null so you can't convert it like this,
ctknox wrote: int id = (int)cmd.ExecuteScalar();
try following to understand:
string str = null;
int i = (int)str;
int j = Convert.ToInt32(str);
While (true) { Human.isLearnable = true; }
|
|
|
|
|
This is a tricky one. ExecuteScalar returns an object. This means that if it returns an int, it will be wrapped as a "boxed" int, similarily if its actually returning something like an unsigned int, you'll get a boxed unsigned int.
Boxed ints can be cast to an int. Unsigned ints can be cast to an int.
Boxed unsigned ints cannot be cast to an int.
int x = (int)5L;
int y = (int)(object)5;
int z = (int)(object)5L;
Convert.ToInt32 works (and I had to look into this before so I'm only going on memory) because it uses the IConvertible interface. (It also does a null-check as well, and returns zero - which might be another reason your casting code could fail).
|
|
|
|
|
Hi all,
This is simple thinking concept query is that-I've an one abstract class that contain some method test() and i've one interface in that with same signature of abstract class method test() name ok fine.(they are just declared)
now i want to implement in one class. And i called and provided some functionalities to the 2 methods, 1 is from abstract class and 1 is from interface .
so how to call particular interface method with the class object that we are implemented in the class and how to call abstract class method with the class object.-
bcoz are 2 same named methods and with the signature also same..........so how would know when we are declared object for class and calling some obj.test()-which method will displayed-is it from abstract or interface belonged method. can u plz give me reply very soon............
modified on Thursday, October 9, 2008 2:50 AM
|
|
|
|
|
Quick answer: Interfaces do not have implementations, classes do. So you don't have two different methods.
The need to optimize rises from a bad design
|
|
|
|
|
I mean that interface has only signature method that method name test(),similarly abstract class has same method test() with same signature of interface.That 2 methods are just declared.
Now in my class i provided functionalities for those methods by inheriting both abstract and interface.
Up to this okey ,now i declared one object for class calling method test() with that object.........so which method will be called ........either abstract class method or interface method.
and why do u get that
|
|
|
|
|
Okay,
Few things: You inherit from abstract class, meaning you get some functionality. You don't inherit from interface, you implement it. This means, that when you implement an interface, you must write the implementation logic for the method defined in an interface.
In your situation, the abstract class may create the implementation for the interface or if the abstract class doesn't do that, you must do it in inherited class
Mika
The need to optimize rises from a bad design
|
|
|
|
|
Sorry u could n't get my question.
First i want to inheritance and implements methods of abstract class and interface(But here the 2 one is abstract class contain test() method,other one interface contain test() method. both are same in signature.)
so I did inheritance and implementation for abstract class and interface in the class.Up to here fine...when declare a object for class and calling test() method with the class object so which of method will be called in the class ,either from implemented interface method or abstract class method.Bcoz they have same signature of two methods that is why am asking.
|
|
|
|
|
Could you post the code or simplified sample. This would greatly help me to see the issue.
The need to optimize rises from a bad design
|
|
|
|
|
Hi,
I have to wirte a Parser, and therfore I would need all the variables and functions definded in a C file. I realiced there is a class called Codedom, but don't know if it is what I search for. If not do you know any other ways to get variables and functions from a C-file?
Thanks for your help.
Dromar
|
|
|
|
|
If you can read the code (for example from a file), compile it and investigate fields, functions etc without actually parsing it yourself, CodeDOM should be useful.
If you really want to parse the original yourself, have a look at for example Yacc[^] which can also be found for Windows.
The need to optimize rises from a bad design
|
|
|
|
|
Just to make clear what I want.
I have a Sourcefile (c, cpp, h...) and want to check if the pass certian programming rules (in my case the MISRA-C 2004 rules). Therefore I need all the Variables and Functions. Can I do that with the Codedom? And if yes can you please post me an example?
|
|
|
|
|