|
If it works, it works. Your experience is not dependent on someone else's experience.
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
|
|
|
|
|
If it works, it works. Your experience is not dependent on someone else's experience.
Hello Sir, I really don't know what you are mentioning about. Just I asked that is there Limitations or Restriction using Titanium Library?
|
|
|
|
|
What is OPC?
What is Titanium Library?
Have you read the doco on both (if it exists)?
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
That's partly going to depend on what version of OPC DA the Mitsubishi MX uses (assuming you are confining yourself to the DA here and aren't interested in AE at all). All your other questions really flow from this.
|
|
|
|
|
Inside a textbox i add many lines of data, ended with a newline(\r\n) for each of it.
For example:
Aaa
Bbb
Ccc
Each line must be read in a backgroundWorker1_DoWork event. Basically, is a time delay of a couple of seconds between jumping to the other line to be read and processed.
My problem is this: - If i add a new line, WHILE the DoWork is running, the textbox.List.lenght is bigger by 1. What should LOAD that updated List, and pass the next line consecutively, to the worker?
At this point i am blank.
What i did so far...
I inverted the list
why? because my processing is not disturbed by each new line added on top, but is accumulating lines at the end, maintaining the lines numbers and contents when it jumps to the next line.
list1.Clear(); label1.Text = "";
list1.AddRange(textBox1.Lines);
list1.Reverse();
for (int i = 0; i < list1.Count; i++)
{
label1.Text += list1[i] + nl;
}
And now the output is:
Ccc
Bbb-updateLine
Aaa
a1-nl
a2-nl
One solution to updating lines by mistake, and avoid re-processing them, is to completely erase the completed "worked" lines from the List and update somewhere else the finished lines.
|
|
|
|
|
i figure out the solution, but i'm still curious whats your resolve though.
|
|
|
|
|
Set up a separate "concurrent queue" for the background worker to access "new lines".
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
|
|
|
|
|
Given the different actions the user can perform on the content of the TextBox ... paste, delete selected lines, etc. ...
I think your strategy should be to perform whatever content enumeration only when the textBox is not in use.
What is the reason you think you need to use a BackGroundWorker here ?
If you must use it, look at the use of 'ManualResetEvent, and use of 'Monitor and 'Lock.
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
|
|
|
|
|
I set the AssemblyInfo in my app to this:
[assembly: AssemblyVersion("1.0.*")]
Yet each time I compile it only increments the Revision, not the Build #. So I end up with something like "1.0.7404.29813", with only the last part ever being incremented.
I display the version info in the status bar of my app, and that's a lot for the users to read back to me during debugging. Is there a way to increment the Build portion each time I compile?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
According to the documentation[^], the default build number should increment daily. You should only ever get 7404 on 9th April 2020.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
suppose you have two lists of the same size, i.e. same number of elements
List<int> a, List<int> b
is it possible to traverse the two lists simultaneously and compare the values? Element 1 in list a to element 1 in list b, element 2 in list a to element 2 in list b, etc. I use a Foreach when traversing lists, but am unsure of how to do a side by side comparison of list b when I am traversing list a.
Thanks
|
|
|
|
|
Use a for instead of a foreach :
for (int i = 0; i < a.Length && i < b.Length; i++)
{
if (a[i] == b[i])
{
...
}
}
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Lists work just like arrays, so you can use either an enumerator (foreach) or you can use an index value:
for(int index = 0; index < someValue; ++index)
{
if (a[index] == b[index])
{
}
else
{
}
}
|
|
|
|
|
If the "lengths" of a and b are equal, you can maintain your own index:
int i = 0;
foreach ( int value in a ){
bool result = (value == b[i++]);
}
Note the suffix (++) operator in this case.
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
|
|
|
|
|
You could also use the Zip extension method, which takes a lambda with two arguments, which is called with the corresponding elements. It yields a IEnumerable of the results of those lambda calls.
var a = {1,2,3,4};
var b = {2,3,4,5}
var c = a.Zip(b, (aa, bb)=> aa * bb).ToList();
var d = {…};
var e = {…};
if (d.Zip(e, (dd, ee)=> dd==ee).All())
{
Truth,
James
modified 13-Apr-20 8:01am.
|
|
|
|
|
One
I have a WPF window which displays a datagrid of Project info. At the top, above the datagrid, are two combo boxes; one for Companies and the other for Project Status. The user can then filter the datagrid by either the Project's company, the Project's status, or both.
When the user opens the window, I want the combo boxes to load asynchronously so the window stays responsive. I want the window to appear, and then load the combobox data. So I have the Window_Loaded event bound to a command, which fires this:
private async Task<bool> WindowLoadedExecuted()
{
await LoadLists();
await LoadProjects();
return true;
}
private async Task<bool> LoadLists()
{
var companyHeaders = await AppCore.BizObject.GetCompanyHeadersAsync();
CompanyHeaders = new List<CompanyHeaderEntity>(companyHeaders);
var projectStatuses = await AppCore.BizObject.GetLookupsAsync(Constants.LookupCategoryProjectStatuses);
ProjectStatuses = new List<LookupEntity>(projectStatuses);
return true;
}
The question here is, is there anything wrong with simply returning a Task instead of Task<bool>? Neither of these methods are going to return anything here. I'm asking because I've seen some articles and posts that say it's not a good idea, but I don't see why. Anything wrong with returning Task instead of Task<t> if there's no return value?
Two
Both of the comboboxes above can trigger a requery. By selecting either a Company or a Status to filter by, I want to reload the datagrid. So, in the properties for both, in their getters, I do:
private CompanyHeaderEntity _SelectedCompanyHeader;
public CompanyHeaderEntity SelectedCompanyHeader
{
get { return _SelectedCompanyHeader; }
set
{
if (_SelectedCompanyHeader != value)
{
_SelectedCompanyHeader = value;
RaisePropertyChanged("SelectedCompanyHeader");
new Task(async () =>
{
await LoadProjects();
}).Start();
}
}
}
To me, this makes sense because selecting a company (instead of none for All), what the user is doing is filtering the list to only those companies. So changing the SelectedCompany property should fire this off.
Yet again, I see posts that seem to discourage this, like this one. Any real reason not to do this? Or is there a better way?
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
modified 9-Apr-20 0:26am.
|
|
|
|
|
If there's no return value, then it makes sense to return Task rather than Task<T> . I've never seen any problems doing that.
For the property setter, I'd be inclined to change it to:
set
{
if (_SelectedCompanyHeader != value)
{
_SelectedCompanyHeader = value;
RaisePropertyChanged(nameof(SelectedCompanyHeader));
_ = LoadProjects();
}
} following the advice from David Fowler:
AspNetCoreDiagnosticScenarios/AsyncGuidance.md at master · davidfowl/AspNetCoreDiagnosticScenarios · GitHub[^]
new Task(fn).Start() should generally be replaced with Task.Run(fn) . But in this case, LoadProjects already returns a Task , so there's no need to create another one.
If the method fails, it will raise the TaskScheduler.UnobservedTaskException[^] event rather than terminating your process.
If you didn't assign the result to a discard, you'd get a IDE0058 warning.
NB: If possible, I'd also be inclined to update your RaisePropertyChanged method to use the CallerMemberName attribute, so that you wouldn't need to pass in the property name when you call the method from a property setter.
protected void RaisePropertyChanged([CallerMemberName] string propertyName = default) { ... }
...
public CompanyHeaderEntity SelectedCompanyHeader
{
get { return _SelectedCompanyHeader; }
set
{
if (_SelectedCompanyHeader != value)
{
_SelectedCompanyHeader = value;
RaisePropertyChanged();
_ = LoadProjects();
}
}
} Caller Information (C#) | Microsoft Docs[^]
If for some reason you can't do that, at least use nameof instead of strings. That way, if you use a refactoring tool to rename the property, the value passed to the RaisePropertyChanged method will be updated to match.
nameof expression - C# reference | Microsoft Docs[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks. I appreciate your input.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
I am trying to make a bot for an external application, in first i used to sendkeys (^a ^c) To the application window after clicking In middle of chat , then get the text from my clipboard And store it in file then read it and answer by sendkeys , and i do all of That under timer control I do all these tasks every 1 second , recently i was searching on another way to do it Because using Sendkeys is taking my processor and pc is going to be more slow further I can't use my pc when my bot is working , after long Search i have found UI automation Which i can access control's another application and get/set text I have found way how to Do it with a notepad , but i don't know or it didn't work for my application I used the below code to get the text from a notepad ,i Want to know the changes I have to do in the code to work in my application , i have downloaded Autoit and spy++
<pre>private void btn_getText_Click(object sender, EventArgs e)
{
PropertyCondition idCond = new PropertyCondition(AutomationElement.AutomationIdProperty,"15");
AutomationElement nameTxt = mainWnd.FindFirst(TreeScope.Descendants, idCond);
if (nameTxt != null)
{
TextPattern txtPattern = nameTxt.GetCurrentPattern(TextPattern.Pattern) as TextPattern;
txt_output.Text = txtPattern.DocumentRange.GetText(-1);
}
}</pre>
I have found , if the application does not support ui textpatteren , it won't work but i don't know how to know that , i don't know The platform of the application made from.
The application i was trying to get text from it www.RankedGaming.Com
Here is a screen shot of the application https://prnt.sc/ruxo2m We type the textbot down and the messages are going to be shown In the top of chat , even i don't know what is that tool Its not going to be written inside its just for read.
|
|
|
|
|
How to read/load a certificate stored in a JKS (Java key stores) file format, in .NET (C#) ?
after loading JKS how to validate certificate in .NET (C#) ?
|
|
|
|
|
It's been a long time since I researched it and wrote code for it.
But I had to create a certificate, and use Linux OpenSSL to convert the certificate to a fully loaded PFX file.
Then wrote a config file called certificate.Development.json and certificate.Production.json so the right certificate would load based on deployment.
As far as validation goes, for me it was a matter of writing code to load, and fine tuning the certificate so it would load, or else it failed to load because it was invalid.
var certificateSettings = config.GetSection("certificateSettings");
var certificateFileName = certificateSettings.GetValue<string>("filename");
var certificatePassword = certificateSettings.GetValue<string>("password");
var certBuffer = File.ReadAllBytes(certificateFileName);
var serverCert = new X509Certificate2(certBuffer, certificatePassword);
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
Hi,
I am reading pulses of nearly 40 sensors in my program. I want to calculate 40parameters based on real-time pulses and also nearly 1000 real-time parameters with calculation formula contained some constant and values calculated based on sensors pulses as the formula variables.
1- The first question is: Is it a good way to use from background running data tables in some datasets to perform all of these tasks at least every one second? what is the best way to perform the described affair?
2- I also want to make a link between data tables columns that when data in other tables inserted, they collect in a table based on one of the columns. For Example, I have the same column in all tables like an auto number, I want to collect data in a collector table automatically with joining (make relation among) tables.
Thank you in advance for your answers
|
|
|
|
|
Use a "one second timer". The timer event calls a method that samples each sensor and does any "aggregating". If it matters, you need to disable / enable the timer on each tick and compensate if necessary (in case of possible reentrancy).
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
|
|
|
|
|
I would definitely disable the timer upon entry to the method!
Assuming you are not storing the sensor details every second.
Once you have done the processing store the results in the database, associated tables with foreign key relationships are a basic operation.
Store the primary record
Get the ID from the just inserted record
insert the related records with the primary key.
wrap the entire operation in a transaction and/or use a stored procedure
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
I wouldn't use a System.Timer because the timer events are the lowest priority events in Windows, so a busy system will ignore/skip events in favor of more important work. I think a thread for each sensor to accept/store new data in the database would be a better solution.
As far as visualizing the data, I would either make the user request new data (with a button click), or set up another thread that reads the new data at a regular interval. The length of the interval would be entirely dependent on the level of performance of your hardware and network (if your database is on a separate machine).
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|