|
i have created a server and client application.
i have ran the server but after a few days of running, it seems to utilize almost 100% of the processor, is this a problem of memory allocation (memory leaks)? if so, what should i do to address this problem? what are the tools which can be used to check if there exists any memory leaks?
|
|
|
|
|
100% utilitization of the processor probably means that there are a lot of threads running around. If you're looking to measure memory consumption, look for Memory Usage and related columns in Task Manager.
Regards
Senthil
|
|
|
|
|
threads seems like a valid reason for 100% cpu
@topic
maybe it's not even the memory itself that's leaking but the thread-resources...
make sure every thread is properly killed (thread.Abort()) after it's done (on WinAPI it really is necessary to do this every time, not sure if the GC collects finished threads so just make sure it's cleaned up)
since you have a client-server-model I guess you're using threads and "sessions" for each user. make sure every session has an inactivity-timeout and it's properly cleaned up (all the threads, all the resources)
so long.
|
|
|
|
|
My application allows user to authenticate to a remote share using domain loggon by invoking mpr.dll
[DllImport("mpr", CharSet=CharSet.Auto)]<br />
public static extern int WNetAddConnection2(<br />
ref NETRESOURCE lpNetResource,<br />
[MarshalAs(UnmanagedType.LPTStr)]<br />
string lpPassword,<br />
[MarshalAs(UnmanagedType.LPTStr)]<br />
string lpUserName,<br />
int dwFlags<br />
);
For example I logged on using following user name: "DOMAIN_1/USERNAME_1".
I would like to find out the user groups (Administrators/Users/etc. ) of user USERNAME_1 within DOMAIN_1.
Could anyone please suggest how to do that?
I have tried using NetUserGetLocalGroups() (netapi32.dll) function but it only retrieved the user groups of USERNAME_1 in the local machine, not in the domain DOMAIN_1. I've tried NetUserGetGroups() too but don't know how to set the parameters to get it right. Please help.
[DllImport("netapi32", CharSet=CharSet.Auto)]<br />
public static extern int NetApiBufferFree(<br />
out IntPtr bufptr <br />
);<br />
<br />
[DllImport("netapi32", CharSet=CharSet.Auto)]<br />
public static extern int NetUserGetLocalGroups(<br />
[MarshalAs(UnmanagedType.LPWStr)]<br />
string servername,<br />
[MarshalAs(UnmanagedType.LPWStr)]<br />
string username,<br />
int level,<br />
int flags,<br />
out IntPtr bufptr,<br />
int prefmaxlen,<br />
out int entriesread,<br />
out int totalentries<br />
);<br />
<br />
<br />
public static ArrayList GetUserGroups(string serverAddress, string userName)
{<br />
<br />
ArrayList groupNames = new ArrayList();<br />
int entriesRead = 0;<br />
int totalEntries = 0;<br />
<br />
IntPtr bufPtr;<br />
<br />
int errorInfo = NetUserGetLocalGroups(serverAddress,userName,0,LG_INCLUDE_INDIRECT,<br />
out bufPtr,MAX_PREFERRED_LENGTH,out entriesRead,out totalEntries);<br />
<br />
<br />
<br />
if(entriesRead> 0)<br />
{<br />
LOCALGROUP_USERS_INFO_0[] RetGroups = new LOCALGROUP_USERS_INFO_0[entriesRead];<br />
IntPtr iter = bufPtr;<br />
for(int i=0; i < entriesRead; i++)<br />
{<br />
RetGroups[i] = (LOCALGROUP_USERS_INFO_0)Marshal.PtrToStructure(iter, typeof(LOCALGROUP_USERS_INFO_0)); <br />
iter = (IntPtr)((int)iter + Marshal.SizeOf(typeof(LOCALGROUP_USERS_INFO_0)));<br />
groupNames.Add(RetGroups[i].groupname);<br />
}<br />
int error = NetApiBufferFree(out bufPtr);<br />
}<br />
<br />
if (errorInfo != NERR_Success)<br />
{ <br />
int error = NetApiBufferFree(out bufPtr); <br />
}<br />
<br />
return groupNames;<br />
}
|
|
|
|
|
|
Look at the System.Management namespace. ManagementObjectSearcher will allow you to query active directory for the info on the domain account. I don't have any code on this computer to offer. You can probably find the query you need by googling on 'wmi user groups' or something.
|
|
|
|
|
Hi Friends,
I have a datagrid (in C#) where in all the rows in a particular cell has hyperlink attribute.
But on ItemDataBound event I want to remove Hypelink attribute from some of the Rows in that particular cell (Conditionally).
My following logic does not seem 2 work
Private dg_ItemDataBound.....
{
e.Item.Cells[1].Attributes.Remove("href");
}
How do I remove hyperlink in some rows in Datagrid??
Regards,
Vipul Mehta
Regards,
Vipul Mehta
Software Engineer
Chenoa Information & Software Services Pvt Ltd
|
|
|
|
|
Hi Friends,
I have a datagrid (in C#) where in all the rows in a particular cell has hyperlink attribute.
But on ItemDataBound event I want to remove Hypelink attribute from some of the Rows in that particular cell (Conditionally).
My following logic does not seem 2 work
Private dg_ItemDataBound.....
{
e.Item.Cells[1].Attributes.Remove("href");
}
How do I remove hyperlink in some rows in Datagrid??
Regards,
Vipul Mehta
Software Engineer
Chenoa Information & Software Services Pvt Ltd
|
|
|
|
|
I coded some kind of electronical Post-it notes and I want to stick them on the Windows Desktop, but how?
The Show Desktop Icon (or Winkey+D) always minimizes my form and i couldn't find any way to prevent that.
Another Idea would be to directly draw my stuff on the Desktop but I don't know how to register to the OnPaint event of the desktop to redraw my stuff.
Thanks a lot in advance.
|
|
|
|
|
>The Show Desktop Icon (or Winkey+D) always minimizes my form and i couldn't find any way to prevent that.
I discoverd that when I click "Show Desktop" that I get the Mesage WM_ACTIVATEAPP which tells me that my app gets deactivated and a thread from the explorer.exe Process gets activated.
So far so good, but how do I prevent now that my app gets minimized?
|
|
|
|
|
hi, anybody has some sample code about how to return a value from a thread, lets say I have a couple of threads running, and I want to return the value of a calculation that its done in the thread, how can achieve this
thanks in advance
|
|
|
|
|
I believe threads must remain void. If you are certain that you won't interfere with variables, just set your calculated value in a class variable within the thread. If you aren't certain you have exclusive access to that variable, then put a lock on it.
|
|
|
|
|
The ThreadStart delegate returns void, so you can't return anything. Look for the BeginInvoke/EndInvoke methods, they allow you to return a value. Or you can use a shared variable to do the job.
Regards
Senthil
|
|
|
|
|
Hi everyone, i need to ask about reading true color image in C#. Thank you
|
|
|
|
|
Read the MSDN. Search on google. The bit depth is irrelevant, C# can read them all.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I’m successfully using SystemTimeToTzSpecificLocalTime to continuously update the local time in a specified time zone. Successfully, that is, until I open another form (using the showdialog method). Once the showdialog method is invoked, the SystemTimeToTzSpecificLocalTime fails continuously --- even after the second form is closed. Same results using the show method. Any ideas?
BTW, this is on Windows XP using Visual C# Express (Beta 1).
Thanks.
|
|
|
|
|
Continuing the thread started here
http://www.codeproject.com/script/comments/forums.asp?forumid=1649&fr=26&select=1039197#xx1039197xx
i would understand something more about windows shell integration.
I've serched on codeproject, on msdn and on google, but i haven't got no good information about.
Can someone show me some good tutorial or explaination?
|
|
|
|
|
What is the practicle way of assigning an array of const values, such as the followiing code does in Visual C++ (6.0):
const double RX_TEST_FREQ[] = {136.15, 155.15, 173.95};
TIA!!!
|
|
|
|
|
You can't declare a const array in C# in the same meaning as in C++. You can declare
readonly double[] RX_TEST_FREQ = new double[] {136.15, 155.15, 173.95};
That would make code like RX_TEST_FREQ = new double[10] invalid, but will still allow RX_TEST_FREQ[1] = 0. In other words, you can't change the array reference, but you can change the array contents.
Regards
Senthil
|
|
|
|
|
Much appreciated! Thanks again.
|
|
|
|
|
I have a Solution with two Projects. Each project has a Form with a Button. I want FormOne in ProjectOne can be opened by clicking the buttonToFormOne on FormTwo in ProjectTwo.
Solution
| |
ProjectOne ProjectTwo
| |
FormOne FormTwo
| |
buttonToFromTwo buttonToFormOne
My questions: How can I create an ProjectOne object in ProjectTwo, and then reference to FormOne?
Can I use " using ProjectOne.FormOne; " statement? Or how?
Thanks a lot.
|
|
|
|
|
You need to reference the project, then you should be able to make that using statement work.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
hi,
i made the event of Document_Opened(),
in the event im checking the file path and according to it i choose
to open or not the doc.
the problem is that if i choose not to open the doc,
i do Document.Close() - the doc is closed but not all of it, the
tab/window of the doc is still in the windows tab.
when i tried to close the doc manually with a button it worked just
fine.
the code is -
private void DocumentEvents_DocumentOpened(Document Document)
{
// check something
Document.Close(vsSaveChanges.vsSaveChangesPrompt);
return;
}
what seems to be the problem?!?!
|
|
|
|
|
Hi All,
Having some trouble selecting data out of a DataTable. Basically I have a column that contains names. Some names are prefixed with an asterisk (*) and some are not. I can't seem to come up with a query to be able to select either the prefixed names or the non-prefixed names. In SQL my queries look like this:
--without the prefix
select * from MyTable where Name not like '*%';
-- with the prefix
select * from MyTable where Name like '*%' ;
How can I achive this using the query syntax a DataTable accepts ? The asterisk (*) is a wildcard in the DataTable's query syntax language so MSDN suggests to escape it with a pair of brackets ([]) but I still can't get it to work. If someone could translate the above two SQL statements into the query syntax the DataTable's Select() method understands it would be much appreciated. Thanks in advance...
|
|
|
|
|
Select * from MyTable where substring(Name,0,1) = '[*]'
Select * from MyTable where substring(Name,0,1) <> '[*]'
Just an untested guess...might not need {} in this case, since not a LIKE statement
Anger is the most impotent of passions. It effects nothing it goes about, and hurts the one who is possessed by it more than the one against whom it is directed.
Carl Sandburg
|
|
|
|