|
I am just giving part of code ,main function of this class is when the user request a file to download, file is broken into chunks,the chunks are added to PendingChunks,the PendingChunks are updated in timer ,the callBack function gets the ChunkAddress of the requested pendingchunks from the server .
public Class:IDisposable
{
Class{
ArrayList PendingChunks=new ArrayList();
timer2 = new System.Threading.Timer(new TimerCallback(getAddressfromServer), null, Timeout.Infinite, Timeout.Infinite);
StartTimer();
}
public void getAddressfromServer(object state)
{
getChunkAddress(PendingChunks)
}
const long TIMER_INTERVAL = 10000L;
private void StartTimer()
{
timer.Change(0, TIMER_INTERVAL);
}
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (!disposed)
{
if (disposing)
{
timer.dispose(); }
disposed = true;
}
}
public void getChunkAddress(ArrayList chnkList)
{
ArrayList chnkAddrList=null;
Chunk c=null;
ChunkAddress chnkAdd;
chnkAddrList = HTTPClass.httpGetChunks(chnkList);
if (chnkAddrList != null)
{
for (int j = 0; j < chnkList.Count; j++)
{
c = (Chunk)chnkList[j];
for (int i = 0; i < chnkAddrList.Count; i++)
{
c.chnkAddress = (ChunkAddress)chnkAddrList[i];
}
}
}
|
|
|
|
|
The code that you show looks basically correct. I can't say anything about the actual code that you use, as you won't show it.
Where do you dispose the object?
---
single minded; short sighted; long gone;
|
|
|
|
|
I am disposing the timer in public void virtual Dispose Method
|
|
|
|
|
Sorry I have no idea how to dispose the object, can u please tell me?
|
|
|
|
|
aruna_koride wrote: Sorry I have no idea how to dispose the object, can u please tell me?
You just call the Dispose method.
This should usually be done by the object that contains the reference to the object to dispose. If you for instance have put the object in a form, that form would call Dispose on the object when the form is closing.
---
single minded; short sighted; long gone;
|
|
|
|
|
As you said I have a recursive loop because I am not stopping to get Chunk Address untill I cleared the PendingChunks ArrayList,may be that is Cause?
Yes I have Called Dispose method in an another class ,triggered by Application Shutdown event of Form,
like this:
using(Class1 c=new Class1)
{
c.Dispose();
}
Is it correct?
Do I need to use using method?or just call Dispose Method?
|
|
|
|
|
aruna_koride wrote: Yes I have Called Dispose method in an another class ,triggered by Application Shutdown event of Form,
like this:
using(Class1 c=new Class1)
{
c.Dispose();
}
Then you are creating a new object and dispose that, that doesn't dispose the object that you use in the rest of the code.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hello everyone,
Why on earth I am getting this message? Everything was working just fine till yesterday and all of the sudden nothing works and I get this Warning and nothing works!
Warning 1 'System.Runtime.InteropServices.UCOMIMoniker' is obsolete: 'Use System.Runtime.InteropServices.ComTypes.IMoniker instead. http://go.microsoft.com/fwlink/?linkid=14202' C:\Documents and Settings\miyaoo\Desktop\directshownet\DirectShow\DShowNET\DsDevice.cs
I have looked at the suggested web address and I get this regarding this error.
System.Runtime.InteropServices.UCOMITypeInfo (Type Obsoleted)
Message: Use System.Runtime.InteropServices.ComTypes.ITypeInfo instead.
I checked the line suggested in the warning and this is what I have.
private static string GetFriendlyName( UCOMIMoniker mon )
what am I suppose to change it to?!!!
Thanx in advance for your help or suggestion.
Khoramdin
|
|
|
|
|
" Use System.Runtime.InteropServices.ComTypes.ITypeInfo instead"
It means, the old one will work, but going forward, it may not on a future version of the framework, and today, they are suggesting there's a better way.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hello Christian,
Thanx for the reply. But everything was working just fine yesterday and I have not change any code since! By the way, since this message started poping up things are not working the way they should be.
I might sound silly but I have no clue what so ever why this message started to pop-up and that is why I am asking. So, could you be more specific and think of me as some one new in this area with limited knowledge.
Thank you for your time,
Khoramdin
-- modified at 19:07 Thursday 8th February, 2007
|
|
|
|
|
I really don't have more to add. You get that warning if you update the version of the framework you're compiling against ( that is, if you change IDE ), and you're using methods that are deprecated.
A google of the error message will probably give you more focused info, from other people with the exact same problem.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hello,
Thanx for all the information. That is why I am puzzled. I didn't change my IDE. I simply went to bed and everything was working and now that I am back on my computer it is not working.
Trust me when I tell you I am reading about my problem as I am asking for help from the people on the site. I am not waiting for someone else to come and solve my problem. All I am asking is information or suggestion to help me out in my search.
Thanx for your time and have a great day,
Khoramdin
|
|
|
|
|
When I try to do a Graphics.FillRectangle() with a new SolidBrush(Color.Red) I get a filled rectangle as expected.
When I try to do this, though:
Color myColor = Color.Red;
...
Graphics.FillRectangle(.... new SolidBrush(myColor), ..)
it fails to draw any color at all. So what do I have to do to convert my stored color into the value it needs to properly draw the color?? I'm using stored colors because I'm exposing the three colors in the Designer.
Thanks.
|
|
|
|
|
It must be something else in the call to FillRectangle. I use the same approach you are all the time, without problems.
|
|
|
|
|
theRealCondor wrote: new SolidBrush(myColor
You shouldn't do this, you should do:
using (SolidBrush theBrush = new SolidBrush(myColor)
{
Graphics.FillRectangle...
}
so that it's Dispose method is called right away. You're leaking GDI resources here.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi Christian,
I plan on implementing that. I'm just running quick deployment to test out why the variable input isn't working. Then I'll go back to the original code that handles the GDI resources correctly.
So have you any thoughts on why I'm not getting my colors?
Michael
|
|
|
|
|
Hello Christian,
Christian Graus wrote: using (SolidBrush theBrush = new SolidBrush(myColor)
{
Graphics.FillRectangle...
}
I never worked with the using "region"(don't know whats the real expression) and now I'm currious about it.
Christian Graus wrote: so that it's Dispose method is called right away. You're leaking GDI resources here.
Does that mean that you would not need to call "theBrush.Dispose();"?
Are there more advantages by using "using"?
Thanks for your time and patients!
All the best,
Martin
|
|
|
|
|
the using keyword simply saves you from having to worry about calling dispose. That's all it does, is insert the code to call dispose, so you can see at the point of creation that an object will not leak.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
|
Wrapping a disposable object within a using (that has rare resources) will always do two things
a) If the object within the using contains a Close() method, then Close is called.
b) The object MUST contain Dispose and Dispose() will be called.
This will happen anytime you exit the using(){} whether due to falling through the bottom or by getting blown off with an exception.
|
|
|
|
|
Thank you for the info!
theRealCondor wrote: or by getting blown off with an exception.
This is what I like most!
All the best,
Martin
|
|
|
|
|
Code is:
DataBinder.Eval(Container, "DataItem.id_produs", "detalii_produs.aspx?id={0}") + DataBinder.Eval(Container, "DataItem.categoria", "categoria={0}")
Result id
url: http://localhost/magazin_admincs/detalii_produs.aspx?id=5categoria=memorii
this is wrong: 5categoria=memorii
i need to show like: 5memorii
|
|
|
|
|
ujupanmester wrote: 5categoria=memorii
You seem to be asking for that.
ujupanmester wrote: categoria={0}
remove the format string altogether if you don't want it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I need 2 parameters
first param to be 5
second param to be memorii
It is posible to be array format?And how it should appears to be good
Thancks
|
|
|
|
|
OK, then put an & in front of memorii.
That's not what you said you wanted, you said you just wanted it to say 5memorii
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|