|
I have this:
List<long> checkedIds = Sensors.Where(x => x.IsChecked).Select(x => x.ID).ToList();
var filterArgs = new
{
Ids = checkedIds,
DateRangeStart = FilterRangeStart,
DateRangeEnd = FilterRangeEnd
};
myWorker.RunWorkerAsync(filterArgs);
How do I get the values in the myWorker_DoWork?
private void myWorker_DoWork(object sender, DoWorkEventArgs e)
{
}
If it's not broken, fix it until it is
|
|
|
|
|
I really hate using anonymous types because they just make your code harder to debug and understand. I strongly suggest replacing the anonymous type with an actual class. I see no reason why you need to use a anonymous type here.
Anonymous types are good for use inside the method where it's defined, not really for passing around to other methods.
The reason being is that you have to define your anonymous type all over again just so you can cast the value back to that type. That's doubling your work and introducing another opportunity to introduce bugs into your code. This is especially true in this case because if you change the type definition, you have to do it in multiple places. YUK!
|
|
|
|
|
You're right
If it's not broken, fix it until it is
|
|
|
|
|
Whilst I agree you should really use a concrete class for anything that leaves the context in which it was created, to answer the question you could use this
private void myWorker_DoWork(object sender, DoWorkEventArgs e)
{
dynamic arg = (dynamic) e.Argument;
Console.WriteLine(arg.DateRangeStart);
}
|
|
|
|
|
hi i want to have text(textbox8) show on form 1 (frmLogin)
shown on form2(files) textbox (textbox1)
my code: textbox1.Text = textbox8.text ,,, error,,,,name(textbox8) login form does not exist in current context
|
|
|
|
|
|
okay this is my code "if (string.IsNullOrEmpty(txtUser.Text)) || (string.IsNullOrEmpty(txtPassword.Text)" i get a invalid expresion on( "||" ) but i have used it before and it worked
|
|
|
|
|
Should be:
if (string.IsNullOrEmpty(txtUser.Text) || string.IsNullOrEmpty(txtPassword.Text))
Use the IDE to check where your matching parentheses are, or should be.
|
|
|
|
|
if (string.IsNullOrEmpty(txtPassword.Text) || (string.IsNullOrEmpty(txtUser.Text)))
MessageBox.Show("field empty.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
Files mf = new Files();
Hide();
mf.ShowDialog();
Close();
}
*theres my code ,its practicly a button that opens another form,and if the fields are empty popup error but when i click ok , the other form still opens, whats the addon code, (== DialogResult.Ok)??
|
|
|
|
|
Yes, you should check the result of the MessageBox.Show message, and perhaps put a better message, and extra button, so the user can continue or cancel. Alternatively, if this error is unrecoverable, you should just exit aftger the message is dismissed by the user.
|
|
|
|
|
i fixed it my fault was i put the ) in but shudve put it iin the end, how do i close it im new here
|
|
|
|
|
jamesmc1535 wrote: how do i close it Close what?
|
|
|
|
|
well not close , u said if its marked as dismissed or something like that i should exit did you mean the program
|
|
|
|
|
I don't know, it all depends on what the application is doing at the time, and what it is supposed to do in these circumstances. You may want to close the main form and then open some other form for further work, or you may just want to close the program.
|
|
|
|
|
okay so this is my problem , i have a button on a form and 2 textboxes,and what i want to do is "create a admin account" where i type into the text boxes "example" username :admin password :admin " and then have it moved on to the next form and if the password/username is incorrect have a message popping up. the messagebox isnt a problem, i just dont know about the username,and will i be able to do it without sql (temporary)?
|
|
|
|
|
You can store the username in your application properties as a temporary measure.
|
|
|
|
|
Hello. I know there is a way to enable and disable speech recognition because you can do pretty much anything in c#. I am stuck on how to enable and disable speech recognition by using my voice. This is the scenario that I want to achieve.
When I say start listening I want my program to accept voice commands. When I say stop listening I want my program to reject all voice commands, apart from "start listening", however only listen out for the command "start listening" to enable full voice command control again.
Does anyone have any ideas on how I can go about doing this?
|
|
|
|
|
Member 11839664 wrote: Does anyone have any ideas on how I can go about doing this? You probably need to start by creating a program that uses the Speech API and recognises those two phrases. Once you have that working you can move on to the more advanced aspects.
|
|
|
|
|
I've used SAPI to do that. Now what do i do
|
|
|
|
|
What code do you currently have?
|
|
|
|
|
No idea. This is your application so only you know what it is supposed to do.
|
|
|
|
|
Set a flag in your application that denotes it's not supposed to process certain commands? Seems kind of obvious to me.
|
|
|
|
|
Hi,
I receive a string from an API like this example:
{"id":"30535","email":"myemail@yahoo.com","first_name":"John","last_name":"Smith","gender":"male","friends":{"data":[{"name":"Helen Ford","id":"68304"},{"name":"Leo Pitt","id":"4732"}]
I'd like to split and save the values into these
string personId
string email
string firstName
string lastName
string gender
and for friends values into an array that contains these values "personId" and "name" (for each set of records)
I'd really appreciate it if someone could help me.
|
|
|
|
|
|