|
Depends what you mean by control
Not sure if having a Concurrent dictionary would help. The problem is that what I return as "latest" should be sorted correctly at all times. The client should not have to re-sort his existing list after each call to get the "latest" - that would defeat its purpose.
To give you an example with numbers (instead of dates), and 3 threads:
A: 1,7,20
B: 2,3,15
C: 4,8
At this point, I can safely return {1,2,3,4,7} , and we'll have
A: 20
B: 15
C: 8
At this point, say I get two more numbers:
A: 20,25
B: 15,17
C: 8
Here, I can't return anything, because I'm not sure what will come after 8. Say I wait a bit and then have:
A: 20,25
B: 15,17
C: 8,16,21
Right now I can return {8,15,16} , and will still have
A: 20,26
B: 17
C: 21
(note: I can't return 20, since I'm not sure what will come next on B)
I wait a bit and have
A: 20,26
B: 17,18
C: 21,23
Right now I can only return {17} . I can't return nor 20, nor 21, because I'm not sure what will come next on B.
Best,
John
-- LogWizard Meet the Log Viewer that makes monitoring log files a joy!
|
|
|
|
|
You can get more numbers down the pipe sooner by pushing.
By “control”, I meant change the code of the providers.
Yes; don’t need a dictionary; just a concurrent queue on the client side and observable collections on the providers:
If the client can see the providers; and all the providers can see the client; and all the providers can see the other providers, then it is possible for all the providers to “push” their numbers, in order, to the client; or the client can be notified any time a new number arrives and can determine whether to “pull” the numbers that were added to the providers’ observable collections. No redundant polling.
In the case of “pushing”:
A pushes 1; B pushes 2,3; C 4; A 7; C 8; B 15; C 16; etc. (since everyone sees everyone else).
Cheers
|
|
|
|
|
Not sure I follow.
1. The client does not know the providers.
2. The providers - lets say they can know about each other.
The thing is - it's not a matter of push or poll, because the algorithm should still be the same, right?
EDIT: In other words, how does a provider know when to "push" a number?
Best,
John
-- LogWizard Meet the Log Viewer that makes monitoring log files a joy!
|
|
|
|
|
I think there are any number of ways; all "correct"; but not the "same".
If all the providers "know" what the other is doing, then they have all the info they need to push: they know what's behind them and beside them. In the sample you posted, there was no "stalling".
One can "subscribe" to events posted by observable collections. If each provider subscribes to each other provider, everyone will always know when anyone adds or removes entries from their collections; this is their cue to decide whether to push (much in the same way the client decides whether to pull from a single queue and how much).
I just don't like polling if I don't have to (as when there is no data). Just more "staying alive".
|
|
|
|
|
Gerry Schmitz wrote:
I just don't like polling if I don't have to (as when there is no data). Just more "staying alive".
I get your point. But in my case, it's pretty much a requirement Sorry, should have mentioned that upfront.
Best,
John
-- LogWizard Meet the Log Viewer that makes monitoring log files a joy!
|
|
|
|
|
What's wrong with using a priority queue, sorted by the event's timestamp?
All "writer" threads write their events to the queue, and the reader thread just has to read the events in order.
Note:
1. Both reading and writing from the Priority Queue require synchronization.
2. An insert/remove from a priority queue is more expensive than insert/remove from a regular queue - O(log(n)) as opposed to O(n).
If your application is not hard real-time, this might be the way to go.
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
|
Hi, guy's.
I get some task from teacher so i really need to help.
Task:
Develop and implement functional classes.
Class of points. The base class (three-dimensional point in the plane with integer coordinates).
Methods: calculate the distance between points; adding the coordinates of two points; input - output on the screen; test the convergence of two points.
The original class: the pixels on the screen (points that have color).
Thank's.
That's what i already done:
public interface ITestPoint
{
double PointDistance();
void OutPoint();
void SetPoint(double x,double y,double _x,double _y);
}
class Point :ITestPoint
{
public double x1, x2, y1, y2;
public double PointDistance()
{
return Math.Sqrt(Math.Pow(x2 - x1, 2) + Math.Pow(y2 - y1, 2));
}
public void OutPoint()
{
Console.WriteLine("Point One({0},{1}); Point Two({2},{3})",x1,y1,x2,y2);
}
public void SetPoint(double x,double y,double _x,double _y)
{
x1 = x;
y1 = y;
x2 = _x;
y2 = _y;
}
}
class Program
{
static void Main(string[] args)
{
Point p = new Point();
p.SetPoint(2,3,5,8);
p.OutPoint();
Console.WriteLine(p.PointDistance());
Console.ReadLine();
}
}
|
|
|
|
|
And?
What help do you need?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
my code not finished and doesn't implement all functions.
|
|
|
|
|
So finish it, and implement all functions!
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.
If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
ok, thank's for the answer.
|
|
|
|
|
You're welcome!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
And what's your question?
This space for rent
|
|
|
|
|
There condition of task that I must do.
|
|
|
|
|
So you came here to tell us that you're working on a project and you're not finished with it yet? That's nice. You better get back to work on it.
|
|
|
|
|
Hi! Everyone.
Can Anybody help me out making my application trial version and disabling some features if it is trial version.
|
|
|
|
|
|
What type of application is it? Is it a phone application? A desktop one? A web based application?
|
|
|
|
|
|
hi everyone
i want to call XML API from OPEN WEATHER website
and then
parse it
and only obtain temperature, humidity and visibilty from there
then all to display in my application
which i have created in C# in MICROSOFT VISUAL STUDIO 2013
it can be displayed in text box , or label etc
and that application
and that i have built is WINDOWS FORM APPLICATION
|
|
|
|
|
what have you tried yet?
Pankaj Maurya
Sr. Software Engineer
Gurgaon, India
|
|
|
|
|
Don't post the same question with added information, add the info to your existing question.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
This page[^] has links to all the API calls you'll need. If I were you, I'd use the JSON results rather than the XML version - JSON is typically a lot smaller than XML.
|
|
|
|
|
I use Parallel.For to do some calculation, when first time i calculate, the speed is slow, but when i calculate again, the speed is better. I guess maybe Parallel.For cost time to load threading .
I want to know how to pre-load Parallel.For before calculate, so that it can be fast at 1st time.
|
|
|
|
|