|
Along the lines of what Dave said, it is possible to "broadcast"; assuming someone is listening. Master and slaves (I've used MODBUS over serial and tcp/ip).
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
modified 14-Dec-20 1:30am.
|
|
|
|
|
Without knowing any details about your app at all (and "it's a WPF app doesn't help), you might be able to do this without a server.
The app could use UDP broadcasts to send a message out so that the same app, using UDP clients listening for the broadcasts could receive them.
The implementation details would be left up to you since you're the only one who knows anything about your app.
|
|
|
|
|
Why are ticks on a DispatcherTimer so unstable? Even at 500 msec. Is there anything you can due to stabilize it?
I am reading analog data from IO and want to update the graph of it. It does not need to be that fast but it looks odd when it keeps jumping at an random intervals. I can deal with long jumps if they are consistent.
So many years of programming I have forgotten more languages than I know.
|
|
|
|
|
I should have noted that I can do a simple while loop with a sleep in it and get better results. It still seems like the tick from DispatcherTimer should do better.
So many years of programming I have forgotten more languages than I know.
|
|
|
|
|
What interval and how far off are we talking?
Windows is not a real-time O/S, so getting an exact interval isn't possible. Events or callbacks are guaranteed to occur NO SOONER THAN your interval. That doesn't mean that it will execute ON that interval.
|
|
|
|
|
I sat the interval for 500 ms. Hard to measure but the trace has a jerky motion. It is much smoother when I use a simple while loop with a sleep in it. Setting the sleep for 20ms gives a nice smooth plot.
So many years of programming I have forgotten more languages than I know.
|
|
|
|
|
Quote: Timers are not guaranteed to execute exactly when the time interval occurs, but they are guaranteed to not execute before the time interval occurs. This is because DispatcherTimer operations are placed on the Dispatcher queue like other operations. When the DispatcherTimer operation executes is dependent on the other jobs in the queue and their priorities.
In other words, you need a separate timing device if you want "stability".
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
It is probably also effected by the debugger in Visual Studio. It really makes the DispatcherTimer useless for delays under a minute.
So many years of programming I have forgotten more languages than I know.
|
|
|
|
|
What is the difference between Show/Hide or Visible/Hidden"? I have some windows I need to keep running in the background. Searching for something yesterday I came accost a comment that said that Show/Hide are obsolete in a Wpf and I should be using the other. I cannot really find a difference except that Visible/Hidden has an event you can tie to the change.
So many years of programming I have forgotten more languages than I know.
|
|
|
|
|
|
I have a UserControl on a TabView that has a DependencyProperty of type Project. Project is an object.
public static readonly DependencyProperty ProjectProperty =
DependencyProperty.Register("Project",
typeof(ProjectEntity),
typeof(PurchaseOrderView),
new PropertyMetadata(null, new PropertyChangedCallback(OnProjectChanged)));
public ProjectEntity Project
{
get { return (ProjectEntity)GetValue(ProjectProperty); }
set { SetValue(ProjectProperty, value); }
}
private static void OnProjectChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
PurchaseOrderView control = (PurchaseOrderView)d;
control.LoadPurchaseOrders();
}
<h1>endregion</h1>
When the control is first loaded, and the binding occurs, Project is set to the instance, and everything works fine.
However, when I select another tab, the control's CTOR and DP's Changed method fire AGAIN and now Project is Null and casues null ref exceptions.
I'm not really sure what's going on. Is it unbinding somehow?? I don't really know how to diagnose this.
I found this article that discusses the Tab Control removing and replacing its content when the tabs change, and I tried using the solution, but it doesn't work.
Anyone have an ideas?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
modified 2-Oct-20 12:49pm.
|
|
|
|
|
I have a bunuch of styles in App.xaml. In just about each, I have this trigger. It enabled the element (Textbox, checkbox, listbox, etc) when the user clicked Edit, AND, if the use has rights. It works well.
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding AreFieldsEnabled}" Value="True" />
<Condition Binding="{Binding CanUserEdit}" Value="True" />
</MultiDataTrigger.Conditions>
<MultiDataTrigger.Setters>
<Setter Property="IsEnabled" Value="True" />
</MultiDataTrigger.Setters>
</MultiDataTrigger>
</Style.Triggers>
The problem is that it's copied & pasted into each of the elements. How can I define this somewhere and resuse it in each element I need it in?
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
hi i have problem load usercontrol in background worker,can anyone help me?
this is my code
Private Sub bwstartup_DoWork(sender As Object, e As DoWorkEventArgs) Handles bwstartup.DoWork
'load some data
LoadData()
bwstartup.ReportProgress(15)
LoadData2()
bwstartup.ReportProgress(20)
Dispatcher.Invoke(Sub() LoadUserControl())
bwstartup.ReportProgress(30)
Dispatcher.Invoke(Sub() LoadUserControl2())
bwstartup.ReportProgress(40)
End Sub
Private Sub bwstartup_ProgressChanged(sender As Object, e As ProgressChangedEventArgs) Handles bwstartup.ProgressChanged
loadingbar.Value = e.ProgressPercentage
End Sub
Private Sub bwstartup_RunWorkerCompleted(sender As Object, e As RunWorkerCompletedEventArgs) Handles bwstartup.RunWorkerCompleted
End Sub
the problem is:
its work on reportprogress(15) to reportprogress(20)
but then freeze until completed LoadUserControl2
so reportprogress(30) is not showing.
thx
|
|
|
|
|
It's your "load" routines that are the problem (and any other code you are not showing).
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
sorry if my information is not complete.it just because on
my "load" routines have full code,it will have long if i paste here.
it is a window contain input form.
i finally solve the problem with changing this :
Dispatcher.Invoke(Sub()
LoadUserControl())
bwstartup.ReportProgress(30)
to this :
action = Sub() LoadUserControl()
Dispatcher.Invoke(DispatcherPriority.Background, action)
bwstartup.ReportProgress(30)
the progressbar start to update again.
thx for the reply
|
|
|
|
|
The code you posted doesn't have anything to do with the problem as far as we can tell.
If you're trying to create and manipulate controls in the background worker, you can't. Controls have to be created on the UI thread, the thread your app started on.
If you're adding data to controls, you cannot do it from a background worker. You cannot touch or modify controls from anything other than the UI thread.
You can load the data you need into data structures in the background worker, but adding that data to controls must be done on the UI thread.
|
|
|
|
|
the problem i want try to solve is like this:
i create application with have some inputform/window
on my button if i call inputform.show the ui is freeze for 0.xx second
cause it have many control inside
so i try to preload the inputform/window n put progressbar to show
to the user.
thx for reply
|
|
|
|
|
How many controls are you talking about?
What do you mean by "preload"? Are you creating a lot of controls? If so, you really need to rethink your form design. If you're loading a lot of data into these controls, again, you really need to rethink your form design. For example, there is no point in loading 100,000 items into a dropdown list. No user will ever put up with using that.
|
|
|
|
|
"preload",i mean is load the modul/window in background at starting program
i can't rethink my form design.cause its not have many control maybe below 20,but every control have to
load data from server so it takes time to completed.
modified 11-Sep-20 0:51am.
|
|
|
|
|
How much data are you talking about?
|
|
|
|
|
Not much about 10.000 rows
But the data is not the problem cause i use backgroundworker to load,the freezing ui when show window that i feel not smooth
|
|
|
|
|
Yeah, you DO NOT load controls with 10,000 records. No user on this planet will put up with scrolling through that much data to find what they want.
There's you're problem.
|
|
|
|
|
but they can search using keyboard,i mean like using combobox then populate all product. so i need to load all the record first.
isn't that right?
|
|
|
|
|
No, it's not.
You take the characters typed in the textbox to have the database return the top 25 to 50 or so records that match the typed characters and populate the dropdown with just those results.
|
|
|
|
|
if i do like that, then every time user typed in textbox,its need to open connection to the server and search the matching text and user needs to tab to search again in dropdownlist.
i think this is not effective... cause it will have problem if the connection is not stable
thx for your suggestion
|
|
|
|