|
.S.Rod. wrote:
when you say "memory usage" you are talking about the WorkingSet, right ?
Nope, as far as I know, WorkingSet reports the correct memory usage of the app. Task manager lies a lot, so it's not something you can trust.
|
|
|
|
|
I don't beleive that Instant Messenger is written with the .NET Framework, so it's probably not a good comparison. For a managed application, 14MB seems reasonable to me. However, if you want to trim your working set, you might try calling this, which might free up 10MB of code that gets used as part of initialization, but might not be needed to run...
Warning: this might not work on Windows 9x. If you've got that in your target configurations, you might want to test for it in Empty below...
using System.Runtime.InteropServices;
namespace PutYourNamespaceHere {
internal class WorkingSet {
internal static void Empty() {
SetProcessWorkingSetSize( -1, -1, -1 );
}
[ DllImport( "Kernel32",
CharSet=System.Runtime.InteropServices.CharSet.Auto,
SetLastError=true)]
private static extern bool SetProcessWorkingSetSize(
int handle, int min, int max);
}
}
Burt Harris
|
|
|
|
|
First, thanks for the cool tip, will try it out in one of my apps.
Is there a sane way of knowing the amount of memory consumed by a .net application, for ex. if I have an application A and application B running, the task manager shows a big chunk of memory used by both these apps.
I'm almost sure the task manager is wrong.
Is it true that the runtime is being shared by these two apps, how do I find out the individual memory consumptions of these two applications.
thanks
Kannan
|
|
|
|
|
I'm pretty sure the runtime will be shared, but it's a little outside my area. Some of the details depend on what OS you are running (9x vs NT based). For this sort of thing, the www.sysinternals.com website has some pretty cool tools. I also highly reccomend their book, as it might provide answers to those sorts of questions.
Burt Harris
|
|
|
|
|
Hello,
NOTE: This is sort of long/detailed.
I know I have been asking a ton of questions lately. Thank you for all of your feedback. I have a custom-drawn listview control that does not highlight the icon while in ListView mode written. I used some of the great painting code provided by Carlos Perez in his UtiltiyLibrary. The problem I am having is that he uses some API SendMessage calls in order to get certain information from the listview. The main thing he is getting is the text of a subitem because when you use Items[1].SubItems[1] (or whatever) you get really weird results. Now the problem I am having is that it doesn't work so well on Win98/ME. I know this is because of the Unicode issue.
I have my SendMessage declared as follows:
[DllImport("user32.dll", CharSet=CharSet.Auto )]<br />
public static extern void SendMessage(IntPtr hWnd, ListViewMessages msg, int wParam, ref LVITEM lParam);
Then it is called with:
SendMessage(Handle, ListViewMessages.LVM_GETITEMTEXTW, row, ref lvi);
ListViewMessages.LVM_GETITEMTEXTW is defined as (LVM_FIRST + 115)
This works great on Win2k. But if I run it on Win98/ME, the Text that is return into lvi is just the first letter. If I change the GETITEMTEXTW to (LVM_FIRST + 45), it will work prefectly on Win98/ME but it does not work correctly on Win2k (just get black bars). I have tried changing the CharSet and making EntryPoint="SendMessageA" on the DLLImport, but nothing works. I have a few other SendMessage calls too that use the Unicode message and I'm afraid that they won't work either.
I have a list of the non-unicode messages, I just need to know to use the same message number is both the Win2k and 98/ME version.
Thanks for reading this really long message.
Jonathan
|
|
|
|
|
To Answer my question for the benefit of others.
From the information that I gave, it was probably practically impossible to answer. It appears that my structure that I had for LV_ITEM had CharSet.Auto set on it. I removed it so that it would be CharSet.Ansi therefore everything concerning converting between ansi and unicode would be taken care of on NT/2000/XP machines. That solved my problem once I set the Messages to be the non-unicode veresion.
|
|
|
|
|
I tried to move a file to a shared fold on another machine within the domain:
File.Move("C:\\test.txt", "\\\\ServerName\\SharedFold\\test.txt");
Every time I got an exception: "Logon failure: unknown user name or bad password." Even if I log on both machine with the same domain user name!
Any one can help me?
RT
|
|
|
|
|
Forgot to note that these codes are in a web app. Win app works OK.
|
|
|
|
|
Does the asp_wp user on the web box have permissions to view/write to that file share?
The actual logged on user's credentials probably aren't even being used because it's running through IIS.
Cheers,
Simon
"The day I swan around in expensive suits is the day I hope someone puts a bullet in my head.", Chris Carter.
my svg article
|
|
|
|
|
In fact I changed the authentication methods for that web site on IIS. I don't use the default IUSER_WORKSTATIONNAME user. Instead I entered a domain user name and password. And I set that shared fold to allow every one can read/write. But still I got "wrong user name or bad password error message".
It really confused me.
RT
|
|
|
|
|
1. Say I have Project A, which references Project B and Project B then references Project C. Why must I add a reference to Projects B AND C in Project A?
2. What can I do to resolve a circular dependency? I have an application that references a class library (separate dll), but that class library requries access to a class in the main application. Hey presto circular dependency
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
Hope this answers your questions...
Even though all of your projects are in the same solution, anything that is outside of a project is still external. Each project would compile down to independant assemblies. So you must create reference by project to make Project A aware of where, exactly, should it go to resolve dependancies. The solution then manages the dependancies and compile hierarchy.
Circular references used to be a problem with prior languages because once you release the object it still hangs around. (memory management would see the existing reference between the two objects and not destroy them) This would be really bad in a case where the object is created many times. So if you create an object and it creates an object and they have circular reference, then when you released the first object it never went away.
Garbage collection now handles circular references better. If you create object B which creates object C which references object B.....when your program ends its' use of object B, it is detected by GC. So it will destroy both object B and C at garbage collection time since the these two objects reference each other but have no parent owner.
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
theRealCondor wrote:
Even though all of your projects are in the same solution
My project dependency question relates to situations where the projects are not even in the same solution. Say for example Projects A, B, and C all have there own solution; from the example I gave, Project A would need to add a reference to both Projects B and C, even though it doesn't use any of the classes provided by Project C.
theRealCondor wrote:
Garbage collection now handles circular references better.
Apologies if I wasn't clear in my original post, but my circular dependency problem is one relating also to projects: Project A (producing A.exe) requires a class in Project B (producing B.dll), but Project B requires a class in Project A. Neither project will build until a reference can be added to the other In C++ I can do this with a forward reference, but C# doesn't seem to support this.
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
|
I'm having the same problem with circular references describes above. Two DLLs that reference each other so neither one can compile without the other already being compiled. Could you elaborate on your solution a bit?
|
|
|
|
|
I´ve an instance of a class that is shared among more than one thread. I need this thread to wait (I mean wait, not sleep inside an infinite loop) until a specific property of this object changes (something like a waitforsingleobject). Does anyone know how can I do this in c# ?
Mauricio Ritter - Brazil
Sonorking now: 100.13560 MRitter
"Th@ langwagje is screwed! It has if's but no end if's!! Stupid php cant even do butuns on forms! VISHAUL BASICS ARE THE FUTSHURE!" - Simon Walton
|
|
|
|
|
hi Mauricio,
check out Thread.Join method.
Cheers
Kannan
|
|
|
|
|
Kannan Kalyanaraman wrote:
check out Thread.Join method.
Not extacly what I want... this method will just wait till the thread ends. What I´m trying to accomplish is this:
MyObject = new MyClass();
MyObject.SomeProperty = "XYZ";
while(<here I need something to suspend this thread until
the "SomeProperty" of the class instance changes">);
{
// Do some processing here
}
Any ideas ?
Mauricio Ritter - Brazil
Sonorking now: 100.13560 MRitter
"Th@ langwagje is screwed! It has if's but no end if's!! Stupid php cant even do butuns on forms! VISHAUL BASICS ARE THE FUTSHURE!" - Simon Walton
|
|
|
|
|
You could just use .Net's equivalent for WaitForSingleObject(), something like:
MyClass MyObject = new MyClass();<br />
<br />
MyObject.SomeProperty = "XYZ";<br />
<br />
Thread thrSomeThread = new Thread(new ThreadStart(ThreadRunner));<br />
thrSomeThread.Start();<br />
<br />
lock(MyObject)<br />
{<br />
Monitor.Wait(MyObject);
}<br />
<br />
public void ThreadRunner()<br />
{<br />
}
public int SomeProperty<br />
{<br />
set<br />
{<br />
m_iProperty = SomeProperty;<br />
<br />
lock(MyObject)<br />
{<br />
Monitor.Pulse(MyObject);
}<br />
}<br />
}
A bit simplified, but that's the jist of it.
Cheers
|
|
|
|
|
that should work... but...
I don´t have any control over the thread that modifys the property.
Mauricio Ritter - Brazil
Sonorking now: 100.13560 MRitter
"Th@ langwagje is screwed! It has if's but no end if's!! Stupid php cant even do butuns on forms! VISHAUL BASICS ARE THE FUTSHURE!" - Simon Walton
|
|
|
|
|
In xp prof window when we click start->Run then run window(with title Run) appears
is there any way in a program that this window appears programatically ?
if it is an exe file where is it?
so that i could start it like a process.
r00d0034@yahoo.com
|
|
|
|
|
To make the window appear programmatically, you need to add reference to shell32 dll in the system32 directory to your c# project.
Once this is done, you create an instance of shellclass and call
the FileRun method.
The code looks like this
<br />
ShellClass obj = new ShellClass();<br />
obj.FileRun();<br />
Hope this helps.
Cheers
Kannan
|
|
|
|
|
You could write a dialog box that does the same thing, basically prompting the user for the name of the exe/program, and then passing the information to ShellExecute or CreateProcess (WIN32 API). If you are using C#, then you could use Process class.
Gaulles
http://www.gaulles.com
|
|
|
|
|
Hello ,
I am trying to pring crystal report without openning a window with the crystal report itself.
I succeeded to print crystal report without parameters by doing:
ReportDocument report = new ReportDocument();
report.Load@"G:\Reports\Rp3Reciept.rpt");
report.PrintOptions.PrinterName = @"\\HPLaserJ5";
report.PrintOptions.PrinterDuplex = PrinterDuplex.Default;
report.PrintToPrinter(1,false,1,1);
and it is working good , but how can I send parameters to reportDocument.
or How can I print report from CrystalReportViewer(becuase to it I can send parameters).
(the printReport() method is virtual , that meens I have to write it?!)
Thank you very much for any answer.
sharon
|
|
|
|
|
You will need to use an object called ParameterFieldDefinitions. It's a collection of the parameters on your report. Here is a simple little function that you may be able to use. It takes a string for the parameter name and in integer for the parameter value. Of course, you could overload this function for other parameter types, but it demonstrates how to set a parameter value on a report. Crystal could certainly make this process easier than they do.
public void SetParameterValue(string szParamName, int iValue)
{
ParameterFieldDefinitions paramFlds = report.DataDefinition.ParameterFields;
ParameterFieldDefinition paramFld = paramFlds[szParamName];
ParameterDiscreteValue discreteValue = new ParameterDiscreteValue();
ParameterValues paramValues = paramFld.CurrentValues;
paramValues.Clear();
discreteValue.Value = iValue;
paramValues.Add(discreteValue);
paramFld.ApplyCurrentValues(paramValues);
}
Ron Ward
|
|
|
|