|
Hello experts,
I'm pondering on the matter for some time now...
How can I tell which object types are managed types, and which are unmanaged?
I was writing a Dispose(bool disposing) method for one of my classes, and the question poped up...
protected virtual void Dispose(bool disposing)
{
if (!disposed)
{
if (disposing)
{
}
}
disposed = true;
}
How do I know which objects should be disposed of in the if (disposing) {...} block?
I guess a FileStream and maybe other streams are unmanaged and should be disposed outside of the block.
What about sockets, timers, etc.?
How to tell??
Thanks in advance,
Shy.
|
|
|
|
|
You should treat any class that implements IDisposable as containing unmanaged resources.
Some classes, like for example MemoryStream, does implement IDisposable eventhough it doesn't contain any unmanaged resources. You should dispose of it anyway, partly just to follow the pattern, but also because the memory management works better if you dispose of all disposable objects.
---
single minded; short sighted; long gone;
|
|
|
|
|
So what should the if (disposing) { ... } block contain?
Should I simply set each non-disposable object to null?
|
|
|
|
|
If an object implements IDisposable , then it most probably implements a finalizer too. In that case, you cannot call Dispose outside the if (disposing) {...} block. The unmanaged resource cleanup is only for unmanaged resources that don't have a Dispose/Finalizer (things like handles you opened yourself).
protected void Dispose(bool disposing)
{
if (disposing)
{
}
}
|
|
|
|
|
That code block is used for anything that you have to do to put your object into an unusable state, as an object is not supposed to be usable after it has been disposed.
You don't have to dereference objects. When the last reference to your object goes away, the references that it contains doesn't count any more.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hi, all!
I'm interested in statistics on:
1) How many .net framework downloads have occurred in total?
2) How many .net developers are known to exist?
3) What's the distribution of answers for questions 1) and 2) between various .net versions?
There should be microsoft statistics I believe. But can't find it. Please, provide if you know.
If there are such statistical data not from microsoft, then please provide me as well.
Thank you, folks.
|
|
|
|
|
I'm trying to port a C++ algorithm to C#, and Im ust say, this is my first time doing so.
Would anyone care to list the corresponidng types from C++ to C#? I've already made some guesses as to what they are:
size_t (I assume it is System.Int32)
uchar_t (I assume it is System.Byte)
uint16_t (UInt16 definitely)
Also, I don't think C# can have the void type in a method's parameter list.
Method(void *sStart, size_t sLen, void *dStart, size_t dLen)
This one line has me puzzled.
Thanks in advance.
ROFLOLMFAO
|
|
|
|
|
You can use as Object
Parwej Ahamad
g_parwez@rediffmail.com
|
|
|
|
|
If possible, I would like to avoid object. Object doesn't even make sense since they are all value types.
ROFLOLMFAO
|
|
|
|
|
Ok, you can use void * pointer in c#
Parwej Ahamad
g_parwez@rediffmail.com
|
|
|
|
|
Behind The Scene wrote: Also, I don't think C# can have the void type in a method's parameter list.
Method(void *sStart, size_t sLen, void *dStart, size_t dLen)
The data type is not "void", it's "void*". It's an unspecified pointer.
---
single minded; short sighted; long gone;
|
|
|
|
|
Right, and a typeless pointer value in C# is an IntPtr.
|
|
|
|
|
I have been having trouble with a circular control reference. I have two controls. The first one is parented to the other in a DragDrop environment. When the parent control is dragged onto the child control a circular reference is created because a parent control cannot be a child to its child control. How could this situation be resolved?
private static void _ctrlParent_DragOver(object sender, DragEventArgs e)
{
try
{
if ( DragDropHandler.CanDropHere((Control)sender, e.Data) )
{
Control cthis = (Control)sender;
e.Effect = DragDropEffects.Move;
Control ctrl = DragDropHandler.GetControl(e.Data, true, true);
if (!(ctrl is IDragDropEnabled))
{
return;
}
if (cthis.Name != ctrl.Name)
{
ctrl.Parent.Controls.Remove(ctrl);
ctrl.Parent = cthis;
cthis.Controls.Add(ctrl);
ctrl.BringToFront();
Point NewLocation = cthis.PointToClient(new Point(e.X, e.Y));
ctrl.Left = NewLocation.X - dragPoint.X;
ctrl.Top = NewLocation.Y - dragPoint.Y;
}
else
{
return;
}
}
else
{
e.Effect = DragDropEffects.None;
}
}
catch (System.Exception ex)
{
MessageBox.Show("Error is " + ex.GetBaseException());
}
}
|
|
|
|
|
Hi ,
I am developing a Client-Server application , I have done some research and found there are three ways to handle multiple client requests.
1. To use old style multithreaded server
2. To use .NET threadPoll worker threads
3. Asynchronous Socket programing
But I am confused that which appproch I shld go.... ?
My clients will run and provide all local info to main application ( Server ) so its the clients who actually will provide info to server/the Main Monitoring application(server) .
Any guidence please to which approch I shd go ?
Clients will be less than 50 ... and the Info they will provide on based on Events generated by Server.
Thanks in advance.
ZINK
-- modified at 8:46 Saturday 3rd March, 2007
HELLO
|
|
|
|
|
(1) You can use socket programming. Open a port of Server and each client send data on that port with self identification.
(2) Handled the each client in thread.......
Parwej Ahamad
g_parwez@rediffmail.com
|
|
|
|
|
Yeh I know that , but my question was which technique I shd use ? and why ?
because I have seen some exampls of client-server written using Asynch methods and it looks very easy n good , but not sure how much stable and efficent it is ...
So please any one who knos the diff between these 3 techniques and reason... ?
HELLO
|
|
|
|
|
As per the developers opinion Asynchronous is best way to developed client-server
architecture. Because Asynchronous sockets use multiple threads from the system thread pool to process network connections. One thread is responsible for initiating the sending or receiving of data; other threads complete the connection to the network device and send or receive the data.
If you would like to get some example please find below link.........
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconUsingNon-blockingClientSocket.asp
Parwej Ahamad
g_parwez@rediffmail.com
|
|
|
|
|
If your application is not a real time control application, then you can ignore any time dependencies. However, if your application is a real time control application, then you will want to consider asynchronous as being your top candidate.
Please note that if you use Asynchronous socket programming, you will be using the thread pool anyway. That's how delegate calls work. It is also the case that the timers in .Net use thread pool threads.
Some problems that are apparent with thread pool threads are that control over the state of a thread pool thread is not easily available. Please be careful when using them. You also need to ensure that code called by the thread pool reports when an error occurs. Throwing an exception may only cause the thread to terminate and not cause the exception to be caught in a place where it can be handled properly.
Phil
|
|
|
|
|
iam workiimh in desktop application c#2005
it's stores applocation
i need to customized datagrid application to appear as sub_rows
for example
row ave the first type then +{plus sing} beside it when use this button all products under that type appears
so when i open the form all types appear and +sing beside it
like the datagrid style when choose datafrom two different table
ma_refay
|
|
|
|
|
I am using the following database connection in my device application
SqlceConnection con=new SqlceConnection ("Data Source=D:\\bd1\\db.sdf");
i kept db.sdf in same location.
but it is giving error message file not found. Help me out...
|
|
|
|
|
I have a VC++ dll and i want to call it in my C# Windows Application.
How can I do it?
|
|
|
|
|
|
Either DllImport or if it is COM registered then Interop.
|
|
|
|
|
hi,
i have a webpage with to textbox named username and password and a datagrid. i have also a add button. whenever i click the add button then the contenct of both textboxes must be fill in the datagrid but i dont want to save the record in the database until i click another button "Submit". I also have to delete the record from the datagrid. then what should i do.
Pankaj
|
|
|
|
|
Using datasets solve the pblm
|
|
|
|