❔ Some bug i guess
Code that works
*inside the static class Static_class_name *
But i want to send more paramters like extra 3 string params which makes the function not want to run
Code that does not work
*inside the static class Static_class_name *
A small modification in the code for Task.Run() that does not work
Now this will work and then function would run
anyone got any suggestions? I will be open to live stream if needed for a better understanding.
It does not make sense that when i put the values param4, 5, 6 directly to the function call, it does not run but when i put it in another variable and then put the variable in the function parameters, it works. (NOTE : all the parameters are coming from windows form application)
param1 -> itemA_numericupdown.value
param2 -> itemB_numericupdown.value
param3 -> itemB_numericupdown.DecimalPlaces
param4 -> itemC_combobox.Text
param5 -> itemD_combobox.Text
param6 -> itemE_combobox.Text
20 Replies
im not too keen on winforms, but it might have something to do with that you are trying to access a UIelement from another thread
when you are creating a new variable it will copy the string still in the uithread.
and since you are now working without a uielements it works
but thats just my 2 cents
but param1,2,3 are also from windows forms
i am not sure why this is happening but i am going to try to put the parameters 4,5,6 as .ToString() so that it will actually copy
let me see how that goes
nope, it does not work
just to make sure, you meant
this doesnt work but
wherever param1/2/3 are coming from, does
yea yeah
in the question i named param1, param2 was becuase it would be more cleaner
in acutal code, its not exactly param1, 2, 3
those are actaul values direclty from windows form
only the last 3 are making the problem
hmm ok
so i put them in variables t1,2,3 and then sent those 3 variables during function call
that works
i still dont know exactly why it does not work if sent directly to function call than putting it in a variable
i am hoping someone can help me in this
btw what exactly do you meant by "Code that does not work" do you get a runtimeexception?
no, after the Task.Run() executes, the function i mentioned inside Task.Run() just does not run
no error, just does not run
now that you have mentioned, let me try putting it in try catch statement
hold on
can you put a await in fronbt of Keyboard_and_Mouse
like Task.Run( () => await Keyboar
basicly
like this?
ok
hold on
cannot use it as the fucntion that uses Task.Run() is not async
Start_function() contains the Task.Run() and its not async
also this Start_function() is being run by a function which run during the buttonclick of windows form
i just tried putting the Task.Run() in try catch, it never got caught
some hidden problem is happening which makes the function not want to run if last 3 parameters are sent directly than putting it in some variables and passing it over
yea there are some shenanigans regarding not awaited tasks
wish it alreayd showed me some error
let me try to send 4 parameters, i never tried that, hold on
there is a explanation for it but i currently dont have the mental capacity to explain it in detail..xD
doesn't work
xD
i think this got something to do with where the data is coming from
i think its something related to combobox.Text
anyway. did you try to not make it a anonymous method and then create a breakpoint in it
nope, let me try
OK, IT WORKS!!!!!!!!!!!
looks like Task.Run() is on drugs
ACiDCA7#8219
yea there are some shenanigans regarding not awaited tasks
Quoted by
<@!267749179470774272> from #Some bug i guess (click here)
React with ❌ to remove this embed.
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.