|
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.
|
|
|
|
|
i have a little bit problem understand english.
only code will helps me understand the idea.
i have thinking about delegate and i try to do this:
public delegate void MethodDEL(object obj);
public static void Start(string Parameter)
{
Thread th = new Thread(new ParameterizedThreadStart(MethodDEL));
th.Start(Parameter);
}
still the same debug error of variable.
i need a type like string to be a type like a method for the thread.
the type of the MethodDEL is deleagate and not method.
if i do:
<pre>
MethodDEL DEL= new MethodDEL(Method);
i will get the same debug error of variable
|
|
|
|
|
OK, here's a method:
public static class Runner
{
public static void
RunThis
(
System.Threading.ParameterizedThreadStart What
,
object Parameter
)
{
(new System.Threading.Thread ( What )).Start ( Parameter ) ;
}
}
But, as you can see, all it does is wrap one statement, so it's hardly worth the trouble.
Here's a method it can execute (yours won't be static):
private static void
Hello
(
object Who
)
{
System.Console.WriteLine ( "Hello, {0}!" , Who ) ;
}
Executing it is as simple as:
RunThis ( new System.Threading.ParameterizedThreadStart ( Hello ) , "world" ) ;
or
(new System.Threading.Thread ( new System.Threading.ParameterizedThreadStart ( Hello ) )).Start ( "world" ) ;
I hope you can see that the RunThis method doesn't reduce the complexity of the calling method very much.
But hold on, I'll go work on a non-static version...
|
|
|
|
|
OK, here's a version of Hello that isn't static, it uses the same RunThis method as my earlier post:
public class MyClass
{
private string greeting = "Hello" ;
private string who = "world" ;
private void
Hello
(
object Who
)
{
System.Console.WriteLine ( "{0}, {1}!" , greeting , Who ) ;
}
public void
SayHello
(
)
{
RunThis ( new System.Threading.ParameterizedThreadStart ( Hello ) , who ) ;
}
}
Again, the RunThis method doesn't add much to the design, but it should do what you need.
|
|
|
|
|
thnx,
but it is a little problem..
in your example there is a method named "hello".
in my classlibary that i will create DLL later from him, the method "hello" not existent.
i will try to explain.
i want to create dll. that open new thread of unknown method, or in other words, start new thread by dynamic method.
the dll that i will create i will add him to the reference on new windows application.
than,between all methods i will choose in the form to create a new thread, from the dll that i created.
but!, i can't compiled the classlibary, because, the method isnt existent there. he existent in the windows application. the class dont know the method.
in your example the method is "hello" and there in no problem to call for new thread because the threadstart see a method name (hello) and not variable(dynamic method mention as string)
i hope you understand me. thnx for the help =]
|
|
|
|
|
sorryy..it's works!!!
thnx my friend for your help!
|
|
|
|
|