Using if statement to load a list before sending it via intent - sending 3 times The Next CEO of Stack OverflowCross-thread operation not valid: Control accessed from a thread other than the thread it was created onURL Encoding using C#Populate XDocument from StringSend Email via C# through Google Apps accountPassing arguments to C# generic new() of templated typeSqlException from Entity Framework - New transaction is not allowed because there are other threads running in the sessionWCF vs ASP.NET Web APIWhy not inherit from List<T>?Send List of Parcelable Object Inside Parcelable Object to Another Activity Using IntentExtract the list of all extras from an Intent in Xamarin.Android and save it in a dictionary
How to write the block matrix in LaTex?
Grabbing quick drinks
Science fiction (dystopian) short story set after WWIII
Why is there a PLL in CPU?
Unreliable Magic - Is it worth it?
Only print output after finding pattern
How to start emacs in "nothing" mode (`fundamental-mode`)
Was a professor correct to chastise me for writing "Prof. X" rather than "Professor X"?
If the heap is initialized for security, then why is the stack uninitialized?
Natural language into sentence logic
Fastest way to shutdown Ubuntu Mate 18.10
What happens if you roll doubles 3 times then land on "Go to jail?"
Where to find order of arguments for default functions
Is HostGator storing my password in plaintext?
Robert Sheckley short story about vacation spots being overwhelmed
Horror movie/show or scene where a horse creature opens its mouth really wide and devours a man in a stables
What can we do to stop prior company from asking us questions?
If I blow insulation everywhere in my attic except the door trap, will heat escape through it?
Should I tutor a student who I know has cheated on their homework?
Why do professional authors make "consistency" mistakes? And how to avoid them?
How to get regions to plot as graphics
How to safely derail a train during transit?
How to Reset Passwords on Multiple Websites Easily?
Need some help with wall behind rangetop
Using if statement to load a list before sending it via intent - sending 3 times
The Next CEO of Stack OverflowCross-thread operation not valid: Control accessed from a thread other than the thread it was created onURL Encoding using C#Populate XDocument from StringSend Email via C# through Google Apps accountPassing arguments to C# generic new() of templated typeSqlException from Entity Framework - New transaction is not allowed because there are other threads running in the sessionWCF vs ASP.NET Web APIWhy not inherit from List<T>?Send List of Parcelable Object Inside Parcelable Object to Another Activity Using IntentExtract the list of all extras from an Intent in Xamarin.Android and save it in a dictionary
Im trying to use if statements to load a list later send it via intent, it seems to be sending it 3 times or looping through to load the string 3 times. I have to send 2 intents to the consuming activity. Can someone help me?
c# xamarin.android
|
show 2 more comments
Im trying to use if statements to load a list later send it via intent, it seems to be sending it 3 times or looping through to load the string 3 times. I have to send 2 intents to the consuming activity. Can someone help me?
c# xamarin.android
2
Where is this code executed? Could you be adding the same delegate three times?
– D Stanley
Mar 21 at 16:42
You mention that you're unsure of the cause. I'd start by adding some basic logging to determine what's happening - is it looping multiple times or is it sending multiple times.
– Wayne Feltham
Mar 21 at 16:43
I have debugged and it is looping 3 times before sending the intent.
– DavidMc
Mar 21 at 16:46
Then I'd suggest that @DStanley is correct. You're either adding the delegate multiple times or the event is firing multiple times. You could try adding some additional logging to pinpoint it more accurately.
– Wayne Feltham
Mar 21 at 16:55
I notice your Items list isn't local - is it possible that you have an event on any of the checkboxes or the Item list itself that is causing the button click to fire as you're adding items to the list within this delegate...or even within the PercentageActivity code? Just to clarify, when you say it's looping 3 time and then sending - you mean the delegate is being called 3 times and then the Intent fires 3 times?
– Wayne Feltham
Mar 21 at 17:02
|
show 2 more comments
Im trying to use if statements to load a list later send it via intent, it seems to be sending it 3 times or looping through to load the string 3 times. I have to send 2 intents to the consuming activity. Can someone help me?
c# xamarin.android
Im trying to use if statements to load a list later send it via intent, it seems to be sending it 3 times or looping through to load the string 3 times. I have to send 2 intents to the consuming activity. Can someone help me?
c# xamarin.android
c# xamarin.android
edited Mar 21 at 22:06
DavidMc
asked Mar 21 at 16:36
DavidMcDavidMc
42
42
2
Where is this code executed? Could you be adding the same delegate three times?
– D Stanley
Mar 21 at 16:42
You mention that you're unsure of the cause. I'd start by adding some basic logging to determine what's happening - is it looping multiple times or is it sending multiple times.
– Wayne Feltham
Mar 21 at 16:43
I have debugged and it is looping 3 times before sending the intent.
– DavidMc
Mar 21 at 16:46
Then I'd suggest that @DStanley is correct. You're either adding the delegate multiple times or the event is firing multiple times. You could try adding some additional logging to pinpoint it more accurately.
– Wayne Feltham
Mar 21 at 16:55
I notice your Items list isn't local - is it possible that you have an event on any of the checkboxes or the Item list itself that is causing the button click to fire as you're adding items to the list within this delegate...or even within the PercentageActivity code? Just to clarify, when you say it's looping 3 time and then sending - you mean the delegate is being called 3 times and then the Intent fires 3 times?
– Wayne Feltham
Mar 21 at 17:02
|
show 2 more comments
2
Where is this code executed? Could you be adding the same delegate three times?
– D Stanley
Mar 21 at 16:42
You mention that you're unsure of the cause. I'd start by adding some basic logging to determine what's happening - is it looping multiple times or is it sending multiple times.
– Wayne Feltham
Mar 21 at 16:43
I have debugged and it is looping 3 times before sending the intent.
– DavidMc
Mar 21 at 16:46
Then I'd suggest that @DStanley is correct. You're either adding the delegate multiple times or the event is firing multiple times. You could try adding some additional logging to pinpoint it more accurately.
– Wayne Feltham
Mar 21 at 16:55
I notice your Items list isn't local - is it possible that you have an event on any of the checkboxes or the Item list itself that is causing the button click to fire as you're adding items to the list within this delegate...or even within the PercentageActivity code? Just to clarify, when you say it's looping 3 time and then sending - you mean the delegate is being called 3 times and then the Intent fires 3 times?
– Wayne Feltham
Mar 21 at 17:02
2
2
Where is this code executed? Could you be adding the same delegate three times?
– D Stanley
Mar 21 at 16:42
Where is this code executed? Could you be adding the same delegate three times?
– D Stanley
Mar 21 at 16:42
You mention that you're unsure of the cause. I'd start by adding some basic logging to determine what's happening - is it looping multiple times or is it sending multiple times.
– Wayne Feltham
Mar 21 at 16:43
You mention that you're unsure of the cause. I'd start by adding some basic logging to determine what's happening - is it looping multiple times or is it sending multiple times.
– Wayne Feltham
Mar 21 at 16:43
I have debugged and it is looping 3 times before sending the intent.
– DavidMc
Mar 21 at 16:46
I have debugged and it is looping 3 times before sending the intent.
– DavidMc
Mar 21 at 16:46
Then I'd suggest that @DStanley is correct. You're either adding the delegate multiple times or the event is firing multiple times. You could try adding some additional logging to pinpoint it more accurately.
– Wayne Feltham
Mar 21 at 16:55
Then I'd suggest that @DStanley is correct. You're either adding the delegate multiple times or the event is firing multiple times. You could try adding some additional logging to pinpoint it more accurately.
– Wayne Feltham
Mar 21 at 16:55
I notice your Items list isn't local - is it possible that you have an event on any of the checkboxes or the Item list itself that is causing the button click to fire as you're adding items to the list within this delegate...or even within the PercentageActivity code? Just to clarify, when you say it's looping 3 time and then sending - you mean the delegate is being called 3 times and then the Intent fires 3 times?
– Wayne Feltham
Mar 21 at 17:02
I notice your Items list isn't local - is it possible that you have an event on any of the checkboxes or the Item list itself that is causing the button click to fire as you're adding items to the list within this delegate...or even within the PercentageActivity code? Just to clarify, when you say it's looping 3 time and then sending - you mean the delegate is being called 3 times and then the Intent fires 3 times?
– Wayne Feltham
Mar 21 at 17:02
|
show 2 more comments
2 Answers
2
active
oldest
votes
Personally, I would recommend that you use the Select Case statement rather than If statement and I would rather go with Radio button where the user is limited to only select one option. In summary, you have two way to go around this.
Considering that he is adding an array of values based on the checkboxes, a radio button wouldnt really be appropriate - equally taking that into account it makes the use of a switch statement something not really practical
– Gibbon
Mar 21 at 16:49
add a comment |
Not sure why it's happening but this might work around it until you can figure it out.
// global variable
var running = false;
btn.Click += delegate
if (!running)
running = true;
if (ckb1.Checked)
Items.Add("Regretful");
if (ckb2.Checked)
Items.Add("Empathic");
if (ckb3.Checked)
Items.Add("Shocked");
if (ckb4.Checked)
Items.Add("Shy");
if (ckb5.Checked)
Items.Add("Irritated");
if (ckb6.Checked)
Items.Add("Lazy");
string result = string.Join(",", Items.ToArray());
var intent = new Intent(this, typeof(PercentageActivity));
StartActivity(intent);
intent.PutExtra("EmOmood", result);
String eventType = "Medium";
intent.PutExtra("mood", eventType);
running = false;
;
c# xamarin.android
shareeditflag
Depending on your answer to my last comment, you may want to move the use of the 'running' variable into the PercentageActivity code...it all depends what exactly is looping.
– Wayne Feltham
Mar 21 at 17:03
add a comment |
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%2f55285234%2fusing-if-statement-to-load-a-list-before-sending-it-via-intent-sending-3-times%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Personally, I would recommend that you use the Select Case statement rather than If statement and I would rather go with Radio button where the user is limited to only select one option. In summary, you have two way to go around this.
Considering that he is adding an array of values based on the checkboxes, a radio button wouldnt really be appropriate - equally taking that into account it makes the use of a switch statement something not really practical
– Gibbon
Mar 21 at 16:49
add a comment |
Personally, I would recommend that you use the Select Case statement rather than If statement and I would rather go with Radio button where the user is limited to only select one option. In summary, you have two way to go around this.
Considering that he is adding an array of values based on the checkboxes, a radio button wouldnt really be appropriate - equally taking that into account it makes the use of a switch statement something not really practical
– Gibbon
Mar 21 at 16:49
add a comment |
Personally, I would recommend that you use the Select Case statement rather than If statement and I would rather go with Radio button where the user is limited to only select one option. In summary, you have two way to go around this.
Personally, I would recommend that you use the Select Case statement rather than If statement and I would rather go with Radio button where the user is limited to only select one option. In summary, you have two way to go around this.
answered Mar 21 at 16:42
WazzieWazzie
300413
300413
Considering that he is adding an array of values based on the checkboxes, a radio button wouldnt really be appropriate - equally taking that into account it makes the use of a switch statement something not really practical
– Gibbon
Mar 21 at 16:49
add a comment |
Considering that he is adding an array of values based on the checkboxes, a radio button wouldnt really be appropriate - equally taking that into account it makes the use of a switch statement something not really practical
– Gibbon
Mar 21 at 16:49
Considering that he is adding an array of values based on the checkboxes, a radio button wouldnt really be appropriate - equally taking that into account it makes the use of a switch statement something not really practical
– Gibbon
Mar 21 at 16:49
Considering that he is adding an array of values based on the checkboxes, a radio button wouldnt really be appropriate - equally taking that into account it makes the use of a switch statement something not really practical
– Gibbon
Mar 21 at 16:49
add a comment |
Not sure why it's happening but this might work around it until you can figure it out.
// global variable
var running = false;
btn.Click += delegate
if (!running)
running = true;
if (ckb1.Checked)
Items.Add("Regretful");
if (ckb2.Checked)
Items.Add("Empathic");
if (ckb3.Checked)
Items.Add("Shocked");
if (ckb4.Checked)
Items.Add("Shy");
if (ckb5.Checked)
Items.Add("Irritated");
if (ckb6.Checked)
Items.Add("Lazy");
string result = string.Join(",", Items.ToArray());
var intent = new Intent(this, typeof(PercentageActivity));
StartActivity(intent);
intent.PutExtra("EmOmood", result);
String eventType = "Medium";
intent.PutExtra("mood", eventType);
running = false;
;
c# xamarin.android
shareeditflag
Depending on your answer to my last comment, you may want to move the use of the 'running' variable into the PercentageActivity code...it all depends what exactly is looping.
– Wayne Feltham
Mar 21 at 17:03
add a comment |
Not sure why it's happening but this might work around it until you can figure it out.
// global variable
var running = false;
btn.Click += delegate
if (!running)
running = true;
if (ckb1.Checked)
Items.Add("Regretful");
if (ckb2.Checked)
Items.Add("Empathic");
if (ckb3.Checked)
Items.Add("Shocked");
if (ckb4.Checked)
Items.Add("Shy");
if (ckb5.Checked)
Items.Add("Irritated");
if (ckb6.Checked)
Items.Add("Lazy");
string result = string.Join(",", Items.ToArray());
var intent = new Intent(this, typeof(PercentageActivity));
StartActivity(intent);
intent.PutExtra("EmOmood", result);
String eventType = "Medium";
intent.PutExtra("mood", eventType);
running = false;
;
c# xamarin.android
shareeditflag
Depending on your answer to my last comment, you may want to move the use of the 'running' variable into the PercentageActivity code...it all depends what exactly is looping.
– Wayne Feltham
Mar 21 at 17:03
add a comment |
Not sure why it's happening but this might work around it until you can figure it out.
// global variable
var running = false;
btn.Click += delegate
if (!running)
running = true;
if (ckb1.Checked)
Items.Add("Regretful");
if (ckb2.Checked)
Items.Add("Empathic");
if (ckb3.Checked)
Items.Add("Shocked");
if (ckb4.Checked)
Items.Add("Shy");
if (ckb5.Checked)
Items.Add("Irritated");
if (ckb6.Checked)
Items.Add("Lazy");
string result = string.Join(",", Items.ToArray());
var intent = new Intent(this, typeof(PercentageActivity));
StartActivity(intent);
intent.PutExtra("EmOmood", result);
String eventType = "Medium";
intent.PutExtra("mood", eventType);
running = false;
;
c# xamarin.android
shareeditflag
Not sure why it's happening but this might work around it until you can figure it out.
// global variable
var running = false;
btn.Click += delegate
if (!running)
running = true;
if (ckb1.Checked)
Items.Add("Regretful");
if (ckb2.Checked)
Items.Add("Empathic");
if (ckb3.Checked)
Items.Add("Shocked");
if (ckb4.Checked)
Items.Add("Shy");
if (ckb5.Checked)
Items.Add("Irritated");
if (ckb6.Checked)
Items.Add("Lazy");
string result = string.Join(",", Items.ToArray());
var intent = new Intent(this, typeof(PercentageActivity));
StartActivity(intent);
intent.PutExtra("EmOmood", result);
String eventType = "Medium";
intent.PutExtra("mood", eventType);
running = false;
;
c# xamarin.android
shareeditflag
answered Mar 21 at 16:53
Wayne FelthamWayne Feltham
466313
466313
Depending on your answer to my last comment, you may want to move the use of the 'running' variable into the PercentageActivity code...it all depends what exactly is looping.
– Wayne Feltham
Mar 21 at 17:03
add a comment |
Depending on your answer to my last comment, you may want to move the use of the 'running' variable into the PercentageActivity code...it all depends what exactly is looping.
– Wayne Feltham
Mar 21 at 17:03
Depending on your answer to my last comment, you may want to move the use of the 'running' variable into the PercentageActivity code...it all depends what exactly is looping.
– Wayne Feltham
Mar 21 at 17:03
Depending on your answer to my last comment, you may want to move the use of the 'running' variable into the PercentageActivity code...it all depends what exactly is looping.
– Wayne Feltham
Mar 21 at 17:03
add a comment |
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%2f55285234%2fusing-if-statement-to-load-a-list-before-sending-it-via-intent-sending-3-times%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
2
Where is this code executed? Could you be adding the same delegate three times?
– D Stanley
Mar 21 at 16:42
You mention that you're unsure of the cause. I'd start by adding some basic logging to determine what's happening - is it looping multiple times or is it sending multiple times.
– Wayne Feltham
Mar 21 at 16:43
I have debugged and it is looping 3 times before sending the intent.
– DavidMc
Mar 21 at 16:46
Then I'd suggest that @DStanley is correct. You're either adding the delegate multiple times or the event is firing multiple times. You could try adding some additional logging to pinpoint it more accurately.
– Wayne Feltham
Mar 21 at 16:55
I notice your Items list isn't local - is it possible that you have an event on any of the checkboxes or the Item list itself that is causing the button click to fire as you're adding items to the list within this delegate...or even within the PercentageActivity code? Just to clarify, when you say it's looping 3 time and then sending - you mean the delegate is being called 3 times and then the Intent fires 3 times?
– Wayne Feltham
Mar 21 at 17:02