|
You might want to consider using a ManualResetEvent[^]. In the background thread use the WaitOne method. When the user selects the city, trigger the event and the background thread should continue its processing of the new weather information, otherwise the timeout period will occur and it will refresh as expected.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
A better solution is a combination of a timer and a backgroundWorker.
Add a Timer with the interval set to 10 minutes In the timer Tick event call a new Method, say UpdateWeather . In your new UpdateWeather method test the backgroundWorker IsBusy property and if it is not busy call RunAsync .
The code to change city can then call the same UpdateWeather method.
If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)
www.JacksonSoft.co.uk
|
|
|
|
|
Understanding that a Timer actually creates a background thread, how is this a "better" solution?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
There is an alternative:
- do not use a BGW
- use a System.Threading.Timer with due time equal to 0, and an infinite period (that makes it a one-shot timer).
- in the timer callback method:
* get the weather info;
* use the InvokeRequired/Invoke pattern[^] to update the GUI;
* set the timer due time to 10 minutes using the Change() method.
- when the user chooses another city, set the timer due time to 0 so it ticks right away.
The advantage is there will be 10 minutes in between weather operations, so they cannot possibly overlap; and you don't need any synchronization. The disadvantage is you need the Invoke stuff for the GUI.
Luc Pattyn [Forum Guidelines] [My Articles]
I only read code that is properly indented, and rendered in a non-proportional font; hint: use PRE tags in forum messages
modified on Monday, November 16, 2009 2:11 PM
|
|
|
|
|
hi is there a way of changing one of the properties of a nullable rectangle.
for example.
private Rectangle? m_RectangleShape;
m_RectangleShape.Value.X = value;
The above is along the lines of what i am looking for, a way to change the x value
Current attempt:
public int X
{
get
{
return m_LocationX;
}
set
{
ShapeRect = new Rectangle(value, m_LocationY, m_SizeX, m_SizeY);
}
}
|
|
|
|
|
Before you can set properties on a nullable rectangle you have to initialise it. It is also best practice to test the HasValue property before setting properties of the value, though not needed at this point.
Rectangle? m_RectangleShape = new Rectangle?();
m_RectangleShape.Value.X = ValueType;
If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)
www.JacksonSoft.co.uk
|
|
|
|
|
I have drawn a graph where at the moment the X points for the bars (drawn using boxes) is draw using numbers, but I now need to draw it using time. Im drawing boxes using a class. It is written in C# opengl.
public void DrawBox(float p_X1, float p_X2, float p_Y1, float p_Y2, float p_R, float p_G, float p_B)
{
X1 = p_X1;
X2 = p_X2;
Y1 = p_Y1;
Y2 = p_Y2;
R = p_R;
G = p_G;
B = p_B;
//Take the values passed in by the constructor
Gl.glBegin(Gl.GL_POLYGON);
Gl.glColor3f(R, G, B);
Gl.glVertex2f(X1, Y1);
Gl.glVertex2f(X2, Y1);
Gl.glVertex2f(X2, Y2);
Gl.glVertex2f(X1, Y2);
Gl.glEnd();
}
Thanks
|
|
|
|
|
Hi there,
Im working a web browser automation project. There is an ajax controlled dropdown list in a web site.
It was like this;
<option value="test1">test1</option>
<option value="test2">test2</option>
<option value="test3">test3</option>
<option value="test4">test4</option>
<option value="test5">test5</option>
When i was selected test2 ajax is working and its giving another div. (I need this div)
I use this codes;
webbrowser1.Document.GetElementsByTagName("select")[0].Document.GetElementsByTagName("option")[1].SetAttribute("selected", "selected");
Its only changing attribute and for this reason it doesnt working ajax.
How can i select option 1?
Thanks.
|
|
|
|
|
Try this:
webbrowser1.Document.GetElementsByTagName("select")[0].InvokeMember("index", 0);
|
|
|
|
|
Sorry, it doesnt working.
I can try a lot of thing but i cant work it.
|
|
|
|
|
And this one:
Object[] args = new Object[1];
args[0] = (Object)"0";
HtmlElement elem = webbrowser1.Document.GetElementsByTagName("select")[0];
elem.InvokeMember("index", args);
|
|
|
|
|
Thank for your replies. But i cant run your codes.
You can be try yours method in this pages (http://fatihunal.somee.com/default.aspx) via a web browser object.
Please click test3 from option box via a web browser object. In this way you will see the problem.
Thanks.
|
|
|
|
|
Yes, at last end i have done it.
webbrowser1.Document.GetElementsByTagName("select")[0].Document.GetElementsByTagName("option")[2].SetAttribute("selected", "selected");
webbrowser1.Document.InvokeScript("__doPostBack");
Its working perfectly.
Thanks for all.
|
|
|
|
|
Hi everyone
I developed a software but somehow (by mistake to be honest) in the beginning I used MS SQL Compact Edition
the system works fine, but I know that compact edition is very limited than Sql Server 2005
According to my algorithm, every entered record creates several tables.
This works good.
But I'm a bit nervous about latter stages
Does this Compact Edition has a table cap?
for example, after 5000. table created, does the DB gives an error like "DB table quantity limit reached" or sth like that?
I know it sounds ridicilous but I've encountered numerous ridicilous errors since I started this project
modified on Monday, November 16, 2009 8:00 AM
|
|
|
|
|
|
Hi,
I've been googling a long time about this, so I thought you peeps might have an answer for me.
I have a application which has been written in .net1.1 a long time ago. I ported that application to .net2.0 (one step at a time ) and left the code the same as much as I could. Everything works, except one thing which I cannot figure out why not.
I have this service, which is listening on a port on the same server as the client runs on. My client in this case is a configuration editor with some basic functionality like getting the time the last synchronisation ran etc.
The service is called the StatusPublisher.
I initialize the the publisher object for use with this call:
*****.IStatusPublisher publisher =
(*****.IStatusPublisher)Activator.GetObject(typeof(*****.IStatusPublisher),
string.Format("tcp://localhost:{0}/StatusPublisher", servicePort));
This is the call which works in .net1.1 but fails in .net2.0:
string returnValue = publisher.NextRun (serviceId);
This call locks up the complete config-tool, kinda forever (killed it after 50 minutes). I had a logging step between every code block, but the logger before the publisher.NextRun() logged fine, everything after was a complete lock up.
Any idea why I can instantiate the publisher object but cannot call a method from it?
The consumer isn't a moron; she is your wife.
modified on Monday, November 16, 2009 7:41 AM
|
|
|
|
|
I can't help you there. I Have search on MSDN and can't find any info on IStatusPublisher. I only can presume that it is not shipped with .Net Framework. If you or your own company is author, then investigate, or contact a technical support on official forum or to author/company
|
|
|
|
|
It's one of our own clases which is an class implementing MarshalByRefObject. It's actually quite the same as MarshalByRefObject only adding some methods.
internal class StatusPublisher : MarshalByRefObject, *****.IStatusPublisher
{
public string NextRun(string serviceId)
{
}
}
Thing is, I can load this class, but I cannot call the methods on it. So it must go wrong higher up the chain, which is .Net code I think.
The consumer isn't a moron; she is your wife.
|
|
|
|
|
have you tried removing Internal keyword?
Or tried add public in front of class?
Is this class a DLL?
Helfdane wrote: Thing is, I can load this class, but I cannot call the methods on it
When you set your debugger, in Quick watch can you use method or what kind of error will throw?
|
|
|
|
|
hw to display context menu on clicking datagrid cell?
|
|
|
|
|
Add a context menu to your form and set the ContactMenu property of the grid to point to your menu.
If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)
www.JacksonSoft.co.uk
|
|
|
|
|
ContactMenu or ContextMenu ?
|
|
|
|
|
i have a problem with the part that recharges and rating when calling of the pay phone.i 'll appreciate your contribution in c# or nedbeans . please help!!! the project is due 27 November 2009. please...
|
|
|
|
|
You need to explain what it is you are trying to do, and what your problem is.
No one will write it for you, but if you have specific problems people will be happy to guide you to the answers.
Post some details of the bit you are stuck on.
Simon
|
|
|
|
|
i do not know c# but i know c++. we are given this project to challenge the we as students. so i need to find the code that recharge the pay phone when you enter the pin voucher then show you the amount you have been charge with
. and as you enter the phone number should establish the connection. i mean just like the mobile phone.
|
|
|
|