|
Rats, I've been using that.
Thanks anyways
------------------------------------
Proud owner of a Peacekeeper barbie
|
|
|
|
|
I have a client and a server program and each has a database on the respective machines. The goal is to have the databases synchronized across the server and all clients in real time, all while having the possibility of the clients working offline from the server.
The way I'm going about it now is I create the app-specific objects from the data in the database on the server (the server will have the actual objects). All clients connect to the server and get proxies to those objects via remoting. When the client modifies a proxy object, the actual object on the server automatically gets updated (duh), and all connected clients recieve an event saying the object was modified, updating all the client GUIs and the client-side databases.
The only catch I see is when the client/server connection goes offline, the client must replace his proxy objects with actual objects read in from his local database. If that's the only catch, I'm willing to live with it.
My question is, is the above way ok to do real-time data synchronization? Would it be better to just pass around messages back and forth? The downside I see to passing around messages is the fact that I'll have to write a lot of code for the server to let all the clients know when an object has been updated. If any of you guys have any thoughts about this or have been down this road before, I'd love to hear it.
Thanks.
---------------------------
He who knows that enough is enough will always have enough.
-Lao Tsu
|
|
|
|
|
What's wrong with just using the BinaryFormatter with a TcpChannel and using events? Works in many in-house remoting apps I've written.
As far as handling offline occurances, you could write a custom RealProxy derivative that determines if the online server is available. If so, it creates the remote proxy. If not, it returns a local proxy. There's a good example of this (only geared for load balancing, but concept is essentially the same) in the "Microsoft .NET Remoting" book from http://www.microsoft.com/mspress[^].
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks for the reply.
Heath Stewart wrote:
What's wrong with just using the BinaryFormatter with a TcpChannel and using events? Works in many in-house remoting apps I've written.
Ah good I was hoping you'd say that. Yeah, nothing wrong from what I can tell, thought it'd be good to ask the experts though.
Heath Stewart wrote:
As far as handling offline occurances, you could write a custom RealProxy derivative that determines if the online server is available. If so, it creates the remote proxy. If not, it returns a local proxy. There's a good example of this (only geared for load balancing, but concept is essentially the same) in the "Microsoft .NET Remoting" book from http://www.microsoft.com/mspress[^].
Interesting! But why use a RealProxy derivative when creating the actual objects would suffice? Maybe there's a benefit I'm not seeing; here I can have transparent proxies to remote objects if online, or the actual objects (read in from local database) if I'm offline. Can you tell me why I should use a RealProxy type instead?
---------------------------
He who knows that enough is enough will always have enough.
-Lao Tsu
|
|
|
|
|
Extending RealProxy lets you do just that pretty easily. You'll still need code that detects if you're online or not, and then creates the proxies accordingly. A RealProxy derivative gives you that kind of control at the source, so to speak. Besides, you can extend the TransparentProxy - it's generated at runtime.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
Yoohoo - finally got my plugin thingy to work:
* Each plugin is loaded into its own thread
* No namespace or class name dependencys (thank you .GetInterfaces )
ok, this is a personal victory, I was working with this for a week now
Credits go to:
Leppie and Heath Stewert for pointing my compass in the right direction !
I ended up using a diffrent approach then the one you guys suggested but it got me started!
Matthew Hazlett
Windows 2000/2003 MCSE
Never got an MCSD, go figure...
|
|
|
|
|
Congrats! Finishing a tough part of a project is always exciting.
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
Is each plugin in a different AppDomain?
|
|
|
|
|
In my PluginTest app.... yes...
Matthew Hazlett
Windows 2000/2003 MCSE
Never got an MCSD, go figure...
|
|
|
|
|
In which case i'd be very interested to see that, i started trying to implement it myself a few weeks ago and got bogged down in various bits of documentation.
|
|
|
|
|
Heh, ok....
Your the second person to ask me this maybe I'll type up an article with what I learned. There are some great examples here like:
http://www.codeproject.com/csharp/PluginsInCSharp.asp
But i'll send you what I made, the code is rough and hasn't been tweaked (Theres a lot I want to add to it) but its a proof of concept. But you can run method's ETC from an external DLL.
I will email it to you.
Matthew Hazlett
Windows 2000/2003 MCSE
Never got an MCSD, go figure...
|
|
|
|
|
Is there a way to measure single character?
Graphics.MeasureString seems to be off.
For example if I have character "i", and the particular font I'm using it's one pixel wide, I'd like to know that it's 1 pixel wide. MeasureString adds some extra space.
|
|
|
|
|
Look at the System.Drawing.Graphics.MeasureCharacterRanges method, it should be all you need. Be forewarned: that method won't measure more than 32 characters. Call it recursively if you need to measure more than 32 characters.
---------------------------
He who knows that enough is enough will always have enough.
-Lao Tsu
|
|
|
|
|
MeasureCharacterRanges makes things even worse.
What i'm doing is drawing text on a curve, so I need to draw each character seperately, because each character is at different x, y position and different rotation angle. The way measurestring (or measurecharacterranges) work is that it looks like it's done using fixed width font.
|
|
|
|
|
You should also make sure that the StringFormat you're using has the StringFormatFlags.MeasureTrailingSpaces excluded.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I am converting a C++ control to a .NET control. In the C++ control in the OnDraw() method I tested for AmbientUserMode, and painted the background with a hashed brush if !AmbientUserMode, or if AmbientUserMode used the BackColor property. How can I test for AmbientUserMode in C# controls?
|
|
|
|
|
Use the protected DesignMode (boolean) property in your control to determine if the control is currently being designed.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
One other way if you want to separate your design code from the runtime code (common in the .NET FCL with the .Design assemblies), attribute your class with a Type string for a ControlDesigner[^] in a different assembly so that your Type string would look like "MyNamespace.Design.MyControlDesigner, MyAssembly.Design" (".Design" isn't necessary - just a common naming convention). The ControlDesigner lets you paint over your control (see ControlDesigner.OnPaintAdornments .
The designer classes and interfaces can be very powerful when used effectively, and most designer support is built right into the .NET FCL (some is provided by the development environment like VS.NET or SharpDevelop). For more information about extending components with design-time capabilities, see Enhancing Design-Time Support[^] on MSDN.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
How can i change the fileattributes of a file (or folder). I will change the Read-only, Hidden, archive,... tags but i can't find it somewhere.
It was no problem to change the creation, last access and last written time, but that class (FileInfo and DirectoryInfo) doesn't have anything to change the attributes of it.
Can you help me?
Jonathan Slenders
|
|
|
|
|
|
See FileInfo.Attributes (inherited form FileSystemInfo ). You can use bitwise operators to change the flags. For instance, to exclude the read-only, hidden, and archive flags, you could do something like this:
FileInfo info = new FileInfo("path");
info.Attributes &= ~(FileAttributes.ReadOnly | FileAttributes.Hidden
| FileAttributes.Archive);
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I want to replace the System Clock ("Date & Time properties") in the sys tray with my own. Does anyone have any ideas on how I can get text to appear as the notify tray icon (just like the windows system clock) ?
|
|
|
|
|
Unless you can fit readable text into a 16x16 pixel icon, you can't. The system clock is not a systray icon and is handled specially by Windows.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I've gor the code to send SMS, but it gives an error message! Please any centilmen can help ? )
The code is as follows:
SMSC objSmsTool = new SMSC();
objSmsTool.PortID = 1;
objSmsTool.MessageText = "Hello, this is a test message";
objSmsTool.Recipient = "0624896641";
objSmsTool.ProviderDialString = "0,0653141414"; // The SMSC provider
Console.WriteLine("Sending message...");
objSmsTool.SendMessage(-1);// -1 means: through service provider
if( objSmsTool.LastError == 0 )
{
// YES, connection established.
Label2.Text = "ok";
Console.WriteLine("Message successfully delivered");
}
else
{
Label2.Text = "Message delivery failed, error: " + objSmsTool.LastError;
}
}
catch(Exception b)
{
Label2.Text = "exception";
}
|
|
|
|