|
Hi,
I have an application (C#) which uses the standard resources in the System.Net library to fire off a WebRequest, pull down a web page, then extract some financial data on it : the data is read from the Response using standard StreamReader techniques. Resources are closed after being used.
The problem I am having is that when I have my app automatically checking every number of minutes the user specifies for updated data, it appears that my WebRequest IS NOT pulling down the latest data on the URL and is accessing some cached version.
My assumptions : using the standard facilities in the System.NET namespace/library is accessing core IE7 functionality. Yes, I have IE7 updated with all the latest security patches.
Using IE7 directly you can, of course, use control-F5 keys to force a refresh of the page.
Appreciate any feedback or ideas as to how to make sure I get the lastest data on the web page in question.
thanks !
Bill Woodruff
dotScience
Chiang Mai, Thailand
"The greater the social and cultural distances between people, the more magical the light that can spring from their contact." Milan Kundera in Testaments Trahis
|
|
|
|
|
You might want to take a look at WebRequest.CachePolicy . Here's a sample snippet from MSDN[^] that does absolutely no caching.
public static WebResponse GetResponseNoCache(Uri uri)
{
HttpRequestCachePolicy policy = new HttpRequestCachePolicy(HttpRequestCacheLevel.Default);
HttpWebRequest.DefaultCachePolicy = policy;
WebRequest request = WebRequest.Create(uri);
HttpRequestCachePolicy noCachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore);
request.CachePolicy = noCachePolicy;
WebResponse response = request.GetResponse();
Console.WriteLine("IsFromCache? {0}", response.IsFromCache);
return response;
}
|
|
|
|
|
Hi Gleat,
Thanks very much for that helpful response !
I'm going to be testing that this week.
best, Bill Woodruff
dotScience
Chiang Mai, Thailand
"The greater the social and cultural distances between people, the more magical the light that can spring from their contact." Milan Kundera in Testaments Trahis
|
|
|
|
|
How would I make a picturebox (pictureBox1 ) "jump"? I mean jump as have a timer move it up for a certain amount of time, and then bring it back down, and when it collides with the ground (a flat pictureBox, pictureBox2 ), the timer disables. I know it's confusing and I ask a lot of crap about this stuff, which all community is sick of, but if you ould answer this (Anyone!), I'd GREATLY appreciate it. THanks in advance.
- "Achieving all knowledge does not mean achieving all wisdom."
- "What makes you smart
?"
|
|
|
|
|
You kind of already answered your question. For Windows Forms applications (as opposed to WPF or DirectX apps), you'd do something like put a Timer on your form. Set an event handler for the timer's Tick event. Inside that tick event, set the .Location of your picture box to a little higher than it was before, e.g.
myPictureBox.Location = new Point(myPictureBox.Location.X, myPictureBox.Location.Y - 1); If you're unsure how to do any of the stuff I mentioned, like setting up an event handler or putting a timer on your form, just ask specifically how to do something and we'll be glad to help.
|
|
|
|
|
Yeah, but it's not that that confused me. How would I make it come back down after it reached a certain point?
- "Achieving all knowledge does not mean achieving all wisdom."
- "What makes you smart
?"
|
|
|
|
|
Figure out what your "certain point" is, then start adjusting it's direction downward. Something like this:
int certainPoint = 50;
bool hasReachedCertainPoint = false;
...
void MyTimerTickHandler(object sender, EventArgs e)
{
if (hasReachedCertainPoint == false)
{
myPictureBox.Location = new Point(myPictureBox.Location.X, myPictureBox.Location.Y - 1);
hasReachedCertainPoint = myPictureBox.Location.Y > certainPoint;
}
else
{
myPictureBox.Location = new Point(myPictureBox.Location.X, myPictureBox.Location.Y + 1);
}
}
|
|
|
|
|
Another thing you might want to look into is WPF. WPF (Windows Presentation Foundation) is the latest UI toolkit for building Windows programs. Inside it is some built-in support for animation, both 2d and 3d animation. Check out WindowsClient.net[^] for more information.
|
|
|
|
|
That's the problem. The Certain Point changes, and if I map out all of them, it would suck. A lot.
- "Achieving all knowledge does not mean achieving all wisdom."
- "What makes you smart
?"
|
|
|
|
|
That's what variables are for - let the certainPoint change as much as it wants; each time your timer tick event fires, and the picture box moves, it will check to see if it's above the certain position and will start moving downward if it is. Does that help?
|
|
|
|
|
Kind of, but say you want the point to be 10 pixels above the box. Every time the box moves up, the point will STILL be 10 pixels up. I see what you mean, but do you see waht I mean? No offense.
- "Achieving all knowledge does not mean achieving all wisdom."
- "What makes you smart
?"
|
|
|
|
|
I don't, sorry. Can you explain a bit more?
(p.s. I'm leaving for sabbath and won't be able to answer your question till Sat or Sun. Maybe the other good CPian folks can help you out in the meantime.)
|
|
|
|
|
I mean that if you just set that Certain Point to be 10 above the box, it will never make it to the point; the point will always be 10 above.
- "Achieving all knowledge does not mean achieving all wisdom."
- "What makes you smart
?"
|
|
|
|
|
When the box first moves, certainpoint will be 10. If you move the box up towards this point by 1 each time, decreament certainpoint by 1. So, if the box pos initially is 100, and certainpoint is 10 above this, the target turnaround point will be boxpos + certainpoint = 100 + 10. Move the box up by one. Boxpos = 101. Take one from CertainPoint : 101 + 9. And so on, until certainpoint is zero. Then negate the delta, and start adding to certainpoint again and mving the box down, until certainpoint is 10. I think...
|
|
|
|
|
How do you decrament an int? I tried this with a timer: --x;, but that just did it once. No every tick.
- "Achieving all knowledge does not mean achieving all wisdom."
- "What makes you smart
?"
|
|
|
|
|
--x; is good. Where is x being assigned? If it is being assigned to 10 in your tick handler, then it will only ever appear to decrement once.
|
|
|
|
|
Yeah. Why does it only do it once, while ++ keeps looping?
- "Achieving all knowledge does not mean achieving all wisdom."
- "What makes you smart
?"
|
|
|
|
|
Post your code - it's got to be something simple. Only saying that as it is nearly midnight and my brain can only cope with 'simple' at the moment!!
|
|
|
|
|
I don't have the code for it. I just had a mishap with code project. It kept wanting to load me in but couldn't! I'm working on the code...
- "Achieving all knowledge does not mean achieving all wisdom."
- "What makes you smart
?"
|
|
|
|
|
I need to decrament the point every time. So how do I do that?
- "Achieving all knowledge does not mean achieving all wisdom."
- "What makes you smart
?"
|
|
|
|
|
Put the decrementing inside your timer tick handler.
|
|
|
|
|
Try this...
(I've just written this without testing it so there may be bugs)
Timer myTimer = new Timer();
bool goingUp = true;
int bottom = 0;
int distance = 0;
public void myTimerTick(object sender, EventArgs e)
{
if (goingUp)
{
myPictureBox.Top--;
if (myPictureBox.Top + myPictureBox.Height < bottom - distance) goingUp = false;
}
else
{
myPictureBox.Top++;
if (myPictureBox.Top + myPictureBox.Height > bottom) myTimer.Stop();
}
}
public void StartJump(int bot, int dist)
{
bottom = bot;
distance = dist;
goingUp = true;
myTimer.Interval = 50;
myTimer.Start();
}
I hope this helps.
You then just need to call StartJump whenever needed.
Matthew Butler
|
|
|
|
|
I tried something like this but it didn't work: BECAUSE IT DIDN"T ++X.
myTimer_Tick(blahbity, blahbity...)<br />
{<br />
int x = 1;<br />
<br />
if (x == 1)<br />
{<br />
move the box up<br />
}<br />
if (x == 2)<br />
{<br />
move the box up<br />
}<br />
if (x == 3)<br />
{<br />
move the box up<br />
}<br />
if (x == 4)<br />
{<br />
move the box DOWN<br />
}<br />
if (x == 5)<br />
{<br />
move the box DOWN<br />
}<br />
if (x == 6)<br />
{<br />
move the box DOWN<br />
}<br />
if (x == 7)<br />
{<br />
x = 1;<br />
myTimer.Enabled = false;<br />
}<br />
<br />
}
- "Achieving all knowledge does not mean achieving all wisdom."
- "What makes you smart
?"
|
|
|
|
|
MasterSharp wrote: myTimer_Tick(blahbity, blahbity...)
{
int x = 1;
if (x == 1)
{
move the box up
}
x will always equal 1. Take the assignment x outside the event handler.
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"This time yesterday, I still had 24 hours to meet the deadline I've just missed today."
|
|
|
|
|
Yeah. I figured it out. BUT, now I need to know how to use more than one key at a time.
protected override ProcessCmdKey(stuff)<br />
{<br />
<br />
switch (keydata)<br />
{<br />
case Keys.Whatever<br />
}<br />
<br />
}
how to use more than one? THanks.
- "Achieving all knowledge does not mean achieving all wisdom."
- "What makes you smart
?"
|
|
|
|