|
You should take a look at .NET Remoting. You get a lot more flexibility, and you could devise a system where the remoting server (could even be in your same process) keeps track of registered clients and sends commands to the right clients based on Type information (judging by your description) and remote method calls. There is some more complexity involved than simple socket programming, but you get a LOT more flexibility because you can chain message handlers (objects that act on message data or even change that message data) and do many other things (like even compressing the message data using a compression sync handler to and from a remote object).
There are several good articles here on CP, and you should get a book like MS Press's ".NET Remoting", which is a good beginner and intermediate book about .NET Remoting.
This way, your threads don't have to keep references to each other and can instead use a broker system through Remoting. You could also broker objects using ContextBoundObject classes, or even with a normal class, but using either remoting or a ContextBoundObject lets you capture messages (for method calls, return messages, etc.) before they are received or sent by the client or server.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Heath,
Believe me, I thought about doing that since it is so easy to do. But that ties them down to the server. The design concept behind the evolving code is for each construct to be an independant, evolving entity with evolution occuring by the 'swarm' through their own network. Each entity is eventually implemented with genetic algorithms to implement the evolution. I saw a hint of something somewhere that suggested a neural network, but I don't know if I want to construct one from scratch in .NET. (could be an interesting undertaking though)
So it will be more of a peer-to-peer communication without a server go-between. (I can always hold that remoting server as a First Build approach, but then I have to address this sooner or later.) I just have to figure out the best approach to take to start the networking --> and that is what I'm trying to figure out.
Thanks for the input!
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
You've got a point, but remoting doesn't necessary have to be a client-server approach, each object would act as both - just communicating with each other. It might not work for your situation, though.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Heath,
The more I thought about this over the weekend, the more I liked it! Each entity could spawn a Communicator component with a fixed message format. For the initial behaviour test, we can make it a simple neural ring where each has a known neighbor (port number) and the last in the chain has the first entity as its' neighbor.
They can pass a standard, serializable message format with a header similar to the TCP packet header. So there is an indicator of the transmitter, receiver (specific or all), and the packet of data to be consumed. Once the packet travels the entire ring back to the originator, the originator communicator logic knows that it is his own and brings the communication circle to an end. (in the case of a non-directed message packet) And if the packet is directed then the movement of the packet stops at that point.
Better yet, we were planning on deploying the ant genetic algorithm in these guys once we knew we could monitor them, and this communication pattern matches the way ants communicate at a basic level. This also positions the entities to be started up independant of "Mom" which is our monitoring program.
Once the behaviour test works, then we incorporate the Ant genetics with swarming (the swarm behavior comes into play when the anthill is attacked). We can provide a digital representation of how the current communication pattern exists, then have the Ant Genetics determine the most efficient path for each to communicate with each other. (a similar method was deployed at a telecom company to determine the shortest route through the phone network for point-to-point) The ant genetic algorithms basically use the methods that the ants use to determine the path from the food they find for a shortest return trip to the anthill. Once they have the formula worked out we can deploy that at startup.
Thanks,
Michael
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
I've been playing with the idea of multicasting .NET objects, by first serialising them to a Memory stream, and then well, multicasting them on a network for those that want to subscribe and listen.
This code snipet shows the kind of thing.
http://www.dotnetextreme.com/articles/multicasting.asp[^]
It would probably be best to deserilize to an Object, and then cast to the object type that is needed.
"Je pense, donc je mange." - Rene Descartes 1689 - Just before his mother put his tea on the table.
Shameless Plug - Distributed Database Transactions in .NET using COM+
|
|
|
|
|
Giles,
This looks interesting as a possibility. But I'm more inclined to implement .NET remoting for the first try. Remoting layers will handle the message packet serialization themselves. But I will keep this one on the back burner.
Michael
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
How do I simply copy the structure of an Access table to another table (no data included) using C#?
Thanks in advance.
|
|
|
|
|
I have a stored procedure which have a return value and a output parameter .I know how to get the value of this parameter but I need to get value of return value too but I don't know how. Thanks
Mazy
No sig. available now.
|
|
|
|
|
On your SqlCommand , add a parameter (whatever name you want, the command builder typically uses @RETURN_VALUE if you want to be consistent). Set the direction parameter in the SqlParameter constructor (or use the Direction property after the SqlParameter is created) and set it to ParameterDirection.ReturnValue . Add this SqlParameter to the command's SqlCommand.Parameters collection. After executing the command, check the SqlParameter.Value .
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks for reply. I use the way you said but when I execute my code I got unhandled error which say my stored procedure expects parameter @RETURN_VALUE which was not supplied. If I delete the row that said Parmater.Direction is ReturnValue then this error does not occured but of course I don't get any return value.Should I add anything to my stored procedure defenition like the way I do for Output parameter?
Mazy
No sig. available now.
|
|
|
|
|
First, you have to make sure you're using a stored proc by setting the SqlCommand.CommantText to the stored proc name, and the SqlCommand.CommandType to CommandType.StoredProcedure . The line that the SQL builder outputs looks something like:
cmd.Parameters.Add(
new SqlParameter("@RETURN_VALUE", SqlDbType.Int, 4,
ParameterDirection.ReturnValue, false, ((Byte)(10)), ((Byte)(0)), "",
DataRowVersion.Current, null)); You use check out the documentatoin for the respective SqlParameter constructor to see what everything means. Basically, a lot of parameters are just fillers so you could create the SqlParameter with the default constructor or a shorter constructor, then assign the properties the way you want.
You should also try playing around with the features that VS.NET provides, like using the Server Explorer to find the Stored Procedure you want and drag it to your form. You can also do this with SqlDataAdapter and many other things like tables (which is especially nice when making strongly-typed DataSet classes). Normally, I don't like "drag-n-drop programming" but in cases like this it sure saves a heck of a lot of time!
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Apparently, PrintOut is not a blocking call, so it's trying to quit immediately after printing. You should check for optional parameters for the Quit method to see if you can override the prompt. I remember seeing one previously.
You should also use synchronous printing, if possible (depends on the COM implementation, so read the Word developer documentation). This should give time for Word to print and then you can quit.
As far as not showing the application, this has been covered before in this forum countless times. It has to do with using a ProcessStartInfo class in Process.Start . Search the comments (always a good idea to do first anyway) for more information.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
one Windos Service is making by C#.NET
when order to Stop service but Service is Some Processing... not Finish
so.. i want to Message Box ("Can not Stop Serveice") ..or
this service can not stop until Service is Some Processing Finish
i want to make
if (someprocessing finish)
{ service.Stop();}
else wait Service.Stop();
How to coding ~~ i do not know~~!!!!!
|
|
|
|
|
I don't know I get your problem correctly but this is I can tell you:
indows service has CanStop property,set it to false and after your proccessing finished set it to true.
CanStop = false;
if(job is done)
CanStop = true;
Mazy
No sig. available now.
|
|
|
|
|
Client --- Unix..
Server --- windows 2000
how does recognize what a data type client send to server?
.................................................................
How to Know server dataType this is Receive Data from Client ???
..................................................................
client send Data
server receive data .. how to konw dataType
if DataType is picture or avi file than save to the other file name and same file type
if DataType is sting than order to SQL Server... "select~~~~from~~~where" + string
if DataType is XML file than save to XML file
Please answer me..
i m Socket Programing at first
|
|
|
|
|
Before sending the data send a datatype maybe as a enumerated type, integer or string.
Maybe create a struct that has a datatype field?
Just some ideas...
HTH
Luke
|
|
|
|
|
You should search CodeProject. There is lots of examples and topics regarding socket programming.
How do you know the data types? You're the one sending and receiving them, so you dictate what those structures are. If you didn't create these structures for either the client or the server, then you need to consult the documentation for the socket client or server that you're trying to talk to. As far as sending files, you just send them using a buffer (a Byte[] array) as is. For strings and XML, just send the character data using the proper encoding (see System.Text.Encoding for more information). You get the Byte[] array for the characters based on an agreed encoding between client and server. You can either assume a single encoding between the two, or send data (much like HTTP, SMTP/MIME, etc.) using an encoding that one dictates.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
hi
i making a program to make dial-up connection and connecting to the net ,i dial with numbers stored in database , i use win API
like(InternetDial() ,InternetHangUp()), but i have two problems
1)InternetDial is dialing with default network connection on pc.
i need to make it taking numbers from database.?????
2) i want to create a new dial-up connection on pc, idont now what function i can use
thank u for advanced help
send me on hz_csharp@hotmail.com
|
|
|
|
|
Assuming you're the same person as before, I already covered this with you: http://www.codeproject.com/script/comments/forums.asp?msg=694424&forumid=1649#xx694424xx[^]. InternetDial can accept a phone number to dial.
Also, creating an actual connection file/config seems to be platform dependent. You should search MSDN Online for ways to do this.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
it try to use internetdial() to take numbers,but i can't because it take name of connection to dial with (existing connecton on pc) as a parameter
plz tell me how to make it take numbers
|
|
|
|
|
I am after a component that will enable users to resize visual objects such as an image at runtime. Just like in a standard art package.
I wrote 1 myself in Delphi and I could port it to C# but I am not sure how I would implement some of the Mouse capture routines...
Besides there must be an open source control that I can use/develop further to achieve what I want.
TIA and Merry Christmas
Luke
|
|
|
|
|
Jinwah wrote:
Besides there must be an open source control that I can use/develop further to achieve what I want.
Well, did you try searching for one? There should be plenty of examples here on CP.
Also, read the documentation for the System.Windows.Forms.Control class. That has all the mouse events and properties you need to do this.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I am new to C#. I am developing a small windows application to train myself with. I faced an issue and can't figure out a good approach to it.
My application needs a few configuration settings that shall be available for altering from users interface. I can build a form etc. but the problem is that I don't know how to keep custom settings. I tried application configuration file, defining a custom section and using IDictionary class instance for reading them. Well, I can read them but can't save them as they only get saved in System.Collections.IDictionary and don't get saved in the application config file.
Is there any simple way to arrange custom configuration and read-write it?
Can someone share a simple understandable example of it?
I hope I explained it clear enough.
Thank you all.
|
|
|
|
|
Take a look at the "Isolated Storage" in the docs and also have a look at this[^] article.
Regards,
Kannan
|
|
|
|
|
I guess this might help and I am trying to read the article.
However, the code in the article looks bit complicated. Can you (someone) maybe give me a simple example of reading/writing a couple of settings?
like nick : real name?
thanks a lot lot lot!
|
|
|
|