|
Should have been a Friday programming quiz.
|
|
|
|
|
hy everyone!
does anyone of you know which encoding has to be used to handle files in windows-1252 correctly via streaming, so no characters are lost or replaced by non printable signs?
thanks!
stephan.
|
|
|
|
|
Stephan,
You can get the 1252 encoder like this.
Encoding coder = Encoding.GetEncoding(1252);
AlanN
|
|
|
|
|
I like to know how much memory is available in the system before I allocate any memory block.
Is there any class or way to get the current memory information from the system.
Thanks you for your help.
|
|
|
|
|
It could change between the time you check and the time you try to allocate anyway. Just try the allocation and catch the exception if any.
|
|
|
|
|
Allocate the minimum amount of memory necessary for the given task.
Also, in c# a memory allocation should not fail unless it exceeds the allowable limit set by the framework for the application, the slowness will be OS based thrashing from VM.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
Thanks for your suggession.
Is there any way to know the amount of memory available programmatically even it might change from time to time. Just like taskbar, I like to know the snapshop of memory in any instance.
Thank you again
|
|
|
|
|
s196675m wrote: Just like taskbar
Not a wheel I would reinvent.
|
|
|
|
|
Is there a way PROGRAMATICALLY( by code) to get memory information just like taskbar shows us.
|
|
|
|
|
|
Thank you for pointing me to the right API. I looked at the API's but I overlooked this function.
|
|
|
|
|
|
Do you know how much memory you need to allocate or are you allocating "as much as you can" for some reason?
If the former (you know what you need) - look at the System.Runtime.MemoryFailPoint in the later .NET versions. It was created to solve that need.
If the latter (you don't) - consider rethinking your app. Seriously, stuff that does like that is a nuisance. Microsoft SQL Server and Exchange Server are two examples (using default settings). That's why they don't play well together in the same machine (without reconfiguring - and as Exchange requires direct Active Directory object property editing for that, it's even more of a nuisance). They keep fooling each others cache allocation strategies, and you end up with system requiring frequent restarts due to memory fragmentation.
--
Peter
|
|
|
|
|
Use System.Management and WMI API.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I've recently come across a solution to a customer problem that involves building a desktop app that interfaces with Quickbase. I searched high and low for some info on how to go about starting this but have come out empty handed. Any Suggestions?
|
|
|
|
|
RobPettipasX11 wrote: I searched high and low for some info on how to go about starting this but have come out empty handed.
Did you try searching on the Internet[^]?
led mike
|
|
|
|
|
|
i created new Classlibary which will be used in my form project
i created a new public method which looks like this/
public delegate void MethodDEL(object obj);
public static void Start(string Method,string Parameter)
{
MethodDEL MM = new MethodDEL(Method);
Thread th = new Thread(new ParameterizedThreadStart(MM));
th.Start(Parameter);
}
the type string (method), will be a method in the form project later.
but now in the class libary it is not reconized as a existent method.
can i take a string a convert him to method object, because the delegate dont help.
im sorry about my english
|
|
|
|
|
asafbs2004 wrote: can i take a string a convert him to method object
Not really, but you can use Reflection to get the method with that name.
|
|
|
|
|
can you show me how to use it on my code that i gave.
thnx
|
|
|
|
|
No, but I'll give some information you may be able to use, but hopefully you'll read up on Reflection yourself.
First you'll need the Type object of whatever you're trying to execute the method on.
The easy ways are:
System.Type t = typeof(MyClass) ;
and
MyClass x = new ( MyClass ) ;
System.Type t = x.GetType() ;
In some of my code I have to do it the hard way, but I won't go into that unless I need to.
Once you have an instance of the Type, you can get a reference to a method with:
System.Reflection.MethodInfo mi = t.GetMember ( methodname ) ;
(There are overloads and a number of other things you may need in the future.)
Then execute it:
mi.Invoke ( null , System.Type.EmptyTypes ) ;
The null is used for static methods , EmptyTypes is handy for methods that don't take parameters.
|
|
|
|
|
how can i use this if the classlibary dont reconized my method.
like i said the method will be created when i create the form and add the dll that created from classlibary..
i had read about reflection, but i kind of lost the way for use this in this commnad:
string method = "BeEXE";
Thread th = new Thread(new ParameterizedThreadStart(method));
|
|
|
|
|
Well, you're probably not explaining the situation very well.
If the method exists, but all you have is the name, then Reflection should work.
If you have the code in a string and want to compile it on the fly, and then run it, that can be done, but I've never done it.
If the method doesn't exist, then there is no way to call it.
|
|
|
|
|
|
OK, I've given this more thought.
Your form will define a method that matches the MethodDEL delegate?
And you then want to pass that method to this method for execution?
A) I see little point in this method, the form can simply create and start the thread itself.
B) Don't pass the name of the method, pass the delegate, that's what delegates are for.
C) If you really want to pass the name of the method to execute, you'll also need to pass a reference to the form.
|
|
|
|