|
There is nothing wrong in your code. Calling the GC.Collect method doesn't guarantee that all objects that can possibly be collected are collected. The garbage collector still decides what to collect and if there is any reason to do any collection at all.
You should shadow the Target property in the class, so that you don't have to cast it when you use it:
public class WeakReference<t> : WeakReference {
public WeakReference(T val) : base(val, false) {}
public new T Target { get { return (T)(base.Target); } }
}</t>
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Once again, thank you very much. Its all due to my misunderstanding that when i use GC.Collect, GC forcibly collects all objects....
|
|
|
|
|
I want to learn my computer name or others computer name. How can I do it? Could please you tell me how I can do it?
|
|
|
|
|
You can use Environment class.
|
|
|
|
|
I found it. the code is System.Environment.MachineName
|
|
|
|
|
I am transfering a very large file through the web service. So, does web service needs to know about the file size? If so, what is the default limit size.
|
|
|
|
|
Web Services are not supposed to be used for large files. Best to use the web service to give a URL and then d/l from http.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
|
Thanks for answering though.
But what should be the default executionTimeoutInSeconds if i were to set 100MB file size limit. Microsoft web site had 400MB and 300 second set. Do i just take a half of 300 seconds or is there any kind of formula.
<pre>Microsoft website
<httpruntime maxmessagelength="409600" executiontimeoutinseconds="300" />
my web.config
<httpruntime maxrequestlength="100000" /></pre>
|
|
|
|
|
It's quite impossible to say since it fully depends on the network.
You can calculate the theoretical throughput for your network based on bandwiths on participating network segments including your internet connection which, in most cases, is the bottleneck and then use an appropriate portion of it or you can do this experimentally.
Also consider which one is more important to you:
- the download most likely succeeds if it's less than for example 400MB => set a long timeout
- server side doesn't get overloaded by too large messages => limit message length.
Addition:
Forgot to say that you should define both elements in web.config, since you obviously need larger valuer thatn the defaults:
- executionTimeoutInSeconds default is 90 seconds
- maxMessageLength default is 4 MB
The need to optimize rises from a bad design.
My articles[ ^]
modified on Tuesday, November 18, 2008 12:48 PM
|
|
|
|
|
Thanks for such a detailed and articulated answer.
|
|
|
|
|
hi,
do we have any class or library that support the binary trees data structures. what about three ways of traversing. I searched google but I am not convinced based on search result. can someone help me please?
|
|
|
|
|
|
You can find the three basic ways of searching a binary tree in most introductory books on data structures. They are: preorder, inorder, and postorder. Your instructor probably covered these in a lecture.
|
|
|
|
|
he did covbered in lectures in c language but I do assignment in Csharp sp to make the assignment I need to have already a class that stores the data in a binary tree fashion. do we have any built in or already written class by others. yes, Once I have that I can write a recirsive routine to do the type of traverses u mentioned above.
|
|
|
|
|
You need to understand the algorithm to store data in a binary tree. It's not hard. Once you understand this, you can write the code yourself.
|
|
|
|
|
Hi,
I'm writing an application in which I'm currently using Console.Writeline() calls to output the various stages. This helps me to develop and debug as I go. However, the time will come when I want to remove all such calls. Can anyone suggest some advice, an article (I have searched on CP) or other source which will tell me how to use debug statements in code which I can then switch off for release.
I was thinking of a logging class - in debug mode it would write to the console but in release mode it would write certain information to a file. The Console.Writeline() methods allows me to do the following:
Console.Writeline("Val1 {0}, Val2 {2}", val1, val2);
How could I write my own function which would accept an unknown number of parameters like this? I would like my function to pass the parameters directly to Console.Writeline() or to a file depending on a flag.
Thanks for any help offered
|
|
|
|
|
Wrap them in #if DEBUG blocks.
#if DEBUG
Console.WriteLine("Debugging");
#endif
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
or
System.Diagnostics.Debug.Write with appropriate listeners.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
Member 5646867 wrote: However, the time will come when I want to remove all such calls.
Replace Console.Writeline with Debug.Writeline ...
If you do a Release build, the calls to the Debug.Writeline should not be included in the executable.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
modified on Tuesday, November 18, 2008 2:38 PM
|
|
|
|
|
I don't know about that. I would think the calls to Debug.WriteLine , or anything else in the Debug class, would be left out though. Console, I think, stays around, even though it's a Windows Forms app.
|
|
|
|
|
Yup. It is the Debug class. Got my wires crossed there for a moment
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Thanks for all your answers - I'll look into each of the suggestions
|
|
|
|
|
Hi,
I am trying to write a code that gets all the files in a folder and returns the name of the file that has the most recent "write" date.
i have wrote this function that gets "path" and should return fileName string.
string[] fileNames = Directory.GetFiles(filePath); // get file names in array
string[] fileDatesList = fileNames; // create fileDateList and initialze(not relevant with what
for (int i = 0; i < fileNames.Length; i++)
{
fileDatesList[i] = Directory.GetLastWriteTime(fileNames[i]).ToString();
}
//TODO write the return(
my problem is with this line:
fileDatesList[i] = Directory.GetLastWriteTime(fileNames[i]).ToString();
lets say i have 3 files in a folder:
abc00, abc01, abc02.
fileNames string array gets all 3 names and stores them.
when i get to the fileDatesList in the for loop, all the entities in
fileNames array are CHANGED with the Date of the file...
example:
before for loop:
fileNames=[abc00,abc01,abc02]
fileDatesList=[abc00,abc01,abc02]
step i=0:
fileNames=[18/11/2008 4:25PM,abc01,abc02]
fileDatesList=[18/11/2008 4:25PM,abc01,abc02]
and so on untill both have only date and time...
i don't understand why it does that why it changes fileNames while changing fileDatesList... although i am not assigning fileDatesList to fileNames in anywhere out of the getLastWriteTime...
thanks a lot!
May The Force Be With You...
|
|
|
|
|
string[] fileDatesList = new string[fileNames.Length];
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|