Is there any limit on the number of WPF DispatchTimers that can be used
I have a WPF project where I have many small control "widgets" I display (these can add up to over a few thousand in some instances)
I now wish to add a small ongoing animation to scroll through one of the text fields to swap between various different values. So I need to add some sort of timer to trigger the animation (or change the value, which would then trigger an animation)
Since there are so many instances, I am not sure whether to do the neater and simpler way I adding a DispatchTimer to the control class (so there is an instance of DispatchTimer for each instance of the control), or, if there is some performance overhead of doing this, have some static, or injected single instance of the DispatchTimer that would then just call a method on each control.
I am always careful here, as in the Winform days, there were always limits on Handles, User objects etc.
Looking at the Source, I do see a HandleRef
being created at line 2982..
SafeNativeMethods.SetTimer(
new HandleRef(this, _window.Value.Handle),
TIMERID_TIMERS,
delta);
however, HandlRef seems to be nothing more than a simple wrapper.
I haven;t examined all the source code, was wondering if anyone had any prior knowledge about this?
Thanks in advance for any help
c# .net wpf
add a comment |
I have a WPF project where I have many small control "widgets" I display (these can add up to over a few thousand in some instances)
I now wish to add a small ongoing animation to scroll through one of the text fields to swap between various different values. So I need to add some sort of timer to trigger the animation (or change the value, which would then trigger an animation)
Since there are so many instances, I am not sure whether to do the neater and simpler way I adding a DispatchTimer to the control class (so there is an instance of DispatchTimer for each instance of the control), or, if there is some performance overhead of doing this, have some static, or injected single instance of the DispatchTimer that would then just call a method on each control.
I am always careful here, as in the Winform days, there were always limits on Handles, User objects etc.
Looking at the Source, I do see a HandleRef
being created at line 2982..
SafeNativeMethods.SetTimer(
new HandleRef(this, _window.Value.Handle),
TIMERID_TIMERS,
delta);
however, HandlRef seems to be nothing more than a simple wrapper.
I haven;t examined all the source code, was wondering if anyone had any prior knowledge about this?
Thanks in advance for any help
c# .net wpf
Are you sure, that you need a timer for this? Why not to use WPF animation Storyboards?
– vasily.sib
Nov 26 '18 at 5:14
So what I will have is, for example, a singleTextBock
which has alist of values
I wish to scroll through. So I need something (a timer) to periodically get the next item in the list and then set the actual single value that the TextBlock is bound to. I will then use theanimation StoryBook
to do the actual animation (eg change opacity, or scroll haven't made up my mind yet). But as I can see, I still need the timer to actually trigger all of this?
– peterc
Nov 26 '18 at 5:20
1
I see now. Then, how about have a singleDispatchTimer
in some shared service (likeITimerService
) which just raises an event (likeITimerService.Elapsed
). Then you can inject this service in your ViewModels, which will change theirCurrentValue
when this event will raise? As far as I know, binded value chage can trigger an animation.
– vasily.sib
Nov 26 '18 at 5:29
Yeah, probably agree with that, ie single injected instance, even if there is no limit (I am guessing there is no limit, but would still be interested in knowing, for any future reference)
– peterc
Nov 27 '18 at 1:24
add a comment |
I have a WPF project where I have many small control "widgets" I display (these can add up to over a few thousand in some instances)
I now wish to add a small ongoing animation to scroll through one of the text fields to swap between various different values. So I need to add some sort of timer to trigger the animation (or change the value, which would then trigger an animation)
Since there are so many instances, I am not sure whether to do the neater and simpler way I adding a DispatchTimer to the control class (so there is an instance of DispatchTimer for each instance of the control), or, if there is some performance overhead of doing this, have some static, or injected single instance of the DispatchTimer that would then just call a method on each control.
I am always careful here, as in the Winform days, there were always limits on Handles, User objects etc.
Looking at the Source, I do see a HandleRef
being created at line 2982..
SafeNativeMethods.SetTimer(
new HandleRef(this, _window.Value.Handle),
TIMERID_TIMERS,
delta);
however, HandlRef seems to be nothing more than a simple wrapper.
I haven;t examined all the source code, was wondering if anyone had any prior knowledge about this?
Thanks in advance for any help
c# .net wpf
I have a WPF project where I have many small control "widgets" I display (these can add up to over a few thousand in some instances)
I now wish to add a small ongoing animation to scroll through one of the text fields to swap between various different values. So I need to add some sort of timer to trigger the animation (or change the value, which would then trigger an animation)
Since there are so many instances, I am not sure whether to do the neater and simpler way I adding a DispatchTimer to the control class (so there is an instance of DispatchTimer for each instance of the control), or, if there is some performance overhead of doing this, have some static, or injected single instance of the DispatchTimer that would then just call a method on each control.
I am always careful here, as in the Winform days, there were always limits on Handles, User objects etc.
Looking at the Source, I do see a HandleRef
being created at line 2982..
SafeNativeMethods.SetTimer(
new HandleRef(this, _window.Value.Handle),
TIMERID_TIMERS,
delta);
however, HandlRef seems to be nothing more than a simple wrapper.
I haven;t examined all the source code, was wondering if anyone had any prior knowledge about this?
Thanks in advance for any help
c# .net wpf
c# .net wpf
asked Nov 26 '18 at 4:59
petercpeterc
1,50222854
1,50222854
Are you sure, that you need a timer for this? Why not to use WPF animation Storyboards?
– vasily.sib
Nov 26 '18 at 5:14
So what I will have is, for example, a singleTextBock
which has alist of values
I wish to scroll through. So I need something (a timer) to periodically get the next item in the list and then set the actual single value that the TextBlock is bound to. I will then use theanimation StoryBook
to do the actual animation (eg change opacity, or scroll haven't made up my mind yet). But as I can see, I still need the timer to actually trigger all of this?
– peterc
Nov 26 '18 at 5:20
1
I see now. Then, how about have a singleDispatchTimer
in some shared service (likeITimerService
) which just raises an event (likeITimerService.Elapsed
). Then you can inject this service in your ViewModels, which will change theirCurrentValue
when this event will raise? As far as I know, binded value chage can trigger an animation.
– vasily.sib
Nov 26 '18 at 5:29
Yeah, probably agree with that, ie single injected instance, even if there is no limit (I am guessing there is no limit, but would still be interested in knowing, for any future reference)
– peterc
Nov 27 '18 at 1:24
add a comment |
Are you sure, that you need a timer for this? Why not to use WPF animation Storyboards?
– vasily.sib
Nov 26 '18 at 5:14
So what I will have is, for example, a singleTextBock
which has alist of values
I wish to scroll through. So I need something (a timer) to periodically get the next item in the list and then set the actual single value that the TextBlock is bound to. I will then use theanimation StoryBook
to do the actual animation (eg change opacity, or scroll haven't made up my mind yet). But as I can see, I still need the timer to actually trigger all of this?
– peterc
Nov 26 '18 at 5:20
1
I see now. Then, how about have a singleDispatchTimer
in some shared service (likeITimerService
) which just raises an event (likeITimerService.Elapsed
). Then you can inject this service in your ViewModels, which will change theirCurrentValue
when this event will raise? As far as I know, binded value chage can trigger an animation.
– vasily.sib
Nov 26 '18 at 5:29
Yeah, probably agree with that, ie single injected instance, even if there is no limit (I am guessing there is no limit, but would still be interested in knowing, for any future reference)
– peterc
Nov 27 '18 at 1:24
Are you sure, that you need a timer for this? Why not to use WPF animation Storyboards?
– vasily.sib
Nov 26 '18 at 5:14
Are you sure, that you need a timer for this? Why not to use WPF animation Storyboards?
– vasily.sib
Nov 26 '18 at 5:14
So what I will have is, for example, a single
TextBock
which has a list of values
I wish to scroll through. So I need something (a timer) to periodically get the next item in the list and then set the actual single value that the TextBlock is bound to. I will then use the animation StoryBook
to do the actual animation (eg change opacity, or scroll haven't made up my mind yet). But as I can see, I still need the timer to actually trigger all of this?– peterc
Nov 26 '18 at 5:20
So what I will have is, for example, a single
TextBock
which has a list of values
I wish to scroll through. So I need something (a timer) to periodically get the next item in the list and then set the actual single value that the TextBlock is bound to. I will then use the animation StoryBook
to do the actual animation (eg change opacity, or scroll haven't made up my mind yet). But as I can see, I still need the timer to actually trigger all of this?– peterc
Nov 26 '18 at 5:20
1
1
I see now. Then, how about have a single
DispatchTimer
in some shared service (like ITimerService
) which just raises an event (like ITimerService.Elapsed
). Then you can inject this service in your ViewModels, which will change their CurrentValue
when this event will raise? As far as I know, binded value chage can trigger an animation.– vasily.sib
Nov 26 '18 at 5:29
I see now. Then, how about have a single
DispatchTimer
in some shared service (like ITimerService
) which just raises an event (like ITimerService.Elapsed
). Then you can inject this service in your ViewModels, which will change their CurrentValue
when this event will raise? As far as I know, binded value chage can trigger an animation.– vasily.sib
Nov 26 '18 at 5:29
Yeah, probably agree with that, ie single injected instance, even if there is no limit (I am guessing there is no limit, but would still be interested in knowing, for any future reference)
– peterc
Nov 27 '18 at 1:24
Yeah, probably agree with that, ie single injected instance, even if there is no limit (I am guessing there is no limit, but would still be interested in knowing, for any future reference)
– peterc
Nov 27 '18 at 1:24
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53475001%2fis-there-any-limit-on-the-number-of-wpf-dispatchtimers-that-can-be-used%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53475001%2fis-there-any-limit-on-the-number-of-wpf-dispatchtimers-that-can-be-used%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Are you sure, that you need a timer for this? Why not to use WPF animation Storyboards?
– vasily.sib
Nov 26 '18 at 5:14
So what I will have is, for example, a single
TextBock
which has alist of values
I wish to scroll through. So I need something (a timer) to periodically get the next item in the list and then set the actual single value that the TextBlock is bound to. I will then use theanimation StoryBook
to do the actual animation (eg change opacity, or scroll haven't made up my mind yet). But as I can see, I still need the timer to actually trigger all of this?– peterc
Nov 26 '18 at 5:20
1
I see now. Then, how about have a single
DispatchTimer
in some shared service (likeITimerService
) which just raises an event (likeITimerService.Elapsed
). Then you can inject this service in your ViewModels, which will change theirCurrentValue
when this event will raise? As far as I know, binded value chage can trigger an animation.– vasily.sib
Nov 26 '18 at 5:29
Yeah, probably agree with that, ie single injected instance, even if there is no limit (I am guessing there is no limit, but would still be interested in knowing, for any future reference)
– peterc
Nov 27 '18 at 1:24