|
I've used the search function to look for articles but didn't find what I needed.
I've been tasked with developing an application to run a simulation. The requirements are to allow one or more servers to run the simulation at the same time sharing the load. Are there any articles or books that can give me a headstart in designing this application?
Thanks!
- Darroll
Darroll
|
|
|
|
|
It depends on what you need help with. If you are looking for a way to efficiently split the workload, it will be hard to give you pointers without knowing the specific problem and how it can be easily divided into smaller tasks. If the problem is setting up the servers, how to connect to them, how to discover their current work loads, etc., then there is a lot of help to be had. Please be a bit more specific as to what kind of assistance you are looking for.
Jeff
|
|
|
|
|
My main concern at the moment is how to manage objects between instances of the servers. The simulation takes multiple vehicles buildings and people. all doing various tasks. There will also be resources that get consumed and created. My thougts were to devide the work load via regions. This way I can segment the load based on the number of objects in a region by resizing the regions. The design of the object menagment and also the best way to transfer and manage objects is what I am looking for.
Thanks!
-- modified at 15:03 Tuesday 20th November, 2007
Darroll
|
|
|
|
|
I would probably have both servers implement identical functionality, which is that either can be initially contacted with the full load. Then, that server delegates some work to the second machine. Use asynchronous web service calls with a delegate to return when the entire task is finished. The second machine can pass info back the same way (asynch calls). If security is an issue, encrypt and authenticate. Make sure that all your objects are serializable, and the easiest way to send would be via soap messages with the serialized object, or you can open a TcpConnection or SSL connection and get a stream from that. As far as object management goes, you will have to have two copies of each object: one on the client, and one on the server. If you find you don't need to keep an object, then pass it on a delete it. I feel like this isn't really helping at all, but I hope I am wrong and I have answered some of your questions.
Jeff
|
|
|
|
|
i hope someone can help me.
is it possible to resize OTHER windows through a C# program? i tried memory editing and that obviously didn't work.
lets assume i have the windows handle. what else would i need to do to resize the window?
(some code would be appreciated)
thanks
-tmpryid
|
|
|
|
|
SendMessage WM_RESIZE to the target window.
|
|
|
|
|
ok, this is what i have so far:
<br />
int hwnd;<br />
int WM_SIZE = 0x0005;<br />
[DllImport("User32.dll")]<br />
public static extern int FindWindow(string strClassName, string strWindowName);<br />
[DllImport("User32.dll")]<br />
public static extern Int32 SendMessage(int hWnd, int Msg, int wParam, int lParam);<br />
<br />
hwnd = FindWindow(null, "Untitled - Paint");<br />
SendMessage(hwnd, WM_SIZE, 0, 0);<br />
but how do i specidy teh width and height i want to resize to?
-tmpryid
|
|
|
|
|
Hmm, the wParam will probably point to a WINDOWPOS struct, which now that i look at it, is the same as the parameters for the SetWindowPos function I posted below.
My current favourite word is: PIE!
Good ol' pie, it's been a while.
|
|
|
|
|
I think there is actually a function for this in user32 or something, one moment whilst i go find it.
Bah, of course SetWindowPos:
http://msdn2.microsoft.com/en-us/library/ms633545.aspx[^]
So, in c# that would be:
[DllImport("user32")]
static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
I've used it before but i can't seem to find the code with the flags and whatnot, so you may need to do a little searching.
Or you can indeed send a message, but then you'll still need to search for the values to send in the message.
My current favourite word is: PIE!
Good ol' pie, it's been a while.
|
|
|
|
|
My mistake, I mentioned WM_RESIZE, that's not it. See this thread[^] for more info.
|
|
|
|
|
I need a problem in an application im writing:
In my app there is a class User
[serializable]
Class User
{
public string _name;
public int _id;
}
i create an instance of this class in memory.
I haev a file in my file system that the the xml represemnatation of this class has to be the header of the file
(without changing the original file)
how can i combine the xml user class and the file in the most correct and eficiant manner - combinig them in memory
to a stram or byte array.
How can i do taht in teh most correct and eficiant manner?
Sample code will be great
Thanks
|
|
|
|
|
I problem in an application im writing:
In my app there is a class User
[serializable]
Class User
{
public string _name;
public int _id;
}
i create an instance of this class in memory.
I haev a file in my file system that the the xml represemnatation of this class has to be the header of the file
(without changing the original file)
how can i combine the xml user class and the file in the most correct and eficiant manner - combinig them in memory
to a stram or byte array.
How can i do taht in teh most correct and eficiant manner?
Sample code will be great
Thanks
|
|
|
|
|
I am attempting to make a class that implements the IList<> interface, but I need to be able to check if the user declared my type using the "readonly" keyword, so I can disable methods like "Add", "Remove", "RemoveAt", etc. Is this done automatically for me, or do I have to do some special programming for it? Thanks,
Jeff
|
|
|
|
|
No, that's not what readonly is for, but you could follow the lead of System.Security.SecureString and add a MakeReadOnly method.
|
|
|
|
|
Then what is readonly for, and why is there an IsReadOnly property required by the IList<> interface?
Jeff
|
|
|
|
|
readonly means the field itself can be assigned once.
IsReadOnly is a property on a list class that simply states to consumers whether elements can be added to the list.
|
|
|
|
|
Oh. Oops, I guess I have to go back and modify all of the code where I thought that readonly was being used within the reference classes to denote locking the collection.
Jeff
|
|
|
|
|
Good thing you asked then.
|
|
|
|
|
Im writing a c# appliction that makes use of threading.timer. According to the msdn i can specify a period The time interval between invocations of callback
,
Does this means the timer will not t\ck until i finish handeling the tick event?
I tried it out and I got two threads in the callback method… how can I solve this?
Im using only one timer so there is no problem of more than one timer .
Sample code will be greate help
thanks
|
|
|
|
|
I beleive that the threading timer runs in its own thread, so you get a tick event every "interval" milliseconds, regardless of what processing you are doing. So if your interval is 20 msec, and it takes you 50 msec to perform the code in your event handler, then you will get more than one tick event processing at a time. I think this explains your comment, "I tried it out and I got two threads in the callback method", but am not certain. If you want the timer event handler to run in the main thread, try using a System.Windows.Forms.Timer, as it calls the handler on the main thread. I'm not sure what System.Timers.Timer does, but you could try to use that as well.
Jeff
|
|
|
|
|
I agree. Use the System.Windows.Forms.Timer.
I've used a couple of options to keep the timer from firing while the previous timer has not completed.
a) Turn off the timer at the beginning of the timer callback then turn it back on as you complete your callback processing (this will affect your interval time, though, so keep that in mind - if your timer is 60 seconds and it takes 2 seconds to process then your effective interval would be 62 seconds in this case)
b) Use a "busy" variable. Set it to true at the start of the callback and false at the end. That way if a subsequent instance of the timer is fired before the previous one is completed then you can simply exit the callback without processing and wait until it fires again.
Darryl Borden
Principal IT Analyst
dborden@eprod.com
|
|
|
|
|
Hi at all.
I made a program which is able to modify images. Now I want it like this:
You choose an image in your explorer, click the right button of your mouse and click "open with" and select my program, which I called PhotoClient.
Ok, so the PhotoClient is starting but the selected image is not in the picturebox1 of my PhotoClient.
So how can I make this come true that I can load an image like this ?
|
|
|
|
|
The file path to the image file will be passed to your program's arguments inside your main method. Inside Program.cs, you probably have a method like this:
static void Main()
{
...
} Change that to
static void Main(string[] arguments)
{
...
} When your app is launched, look at the arguments parameter. It should contain the file path to the image that Windows Explorer passed to you.
|
|
|
|
|
Thanks for your help.
I put the "string[] arguments" in the Main, and now ? What do you mean with "look at the arguments" ?
How can I transfer the file path into my Form1 ?
|
|
|
|
|
Change the default constructor to take a string array, then change the line "new Form1();" to "new Form1(arguments);". Then in your constructor, use a foreach to try and open the files specified.
Jeff
|
|
|
|