C Encountered such a problem in programming

Updated on technology 2024-05-13
6 answers
  1. Anonymous users2024-02-10

    If you use multithreading, you can, sleep in another thread, and then use the delegate to solve the main thread to change the lable text.

    Here's how to name your lable as lable1

    using ;

    Runs when the main form loads.

    private void form1_load(object sender, eventargs e)

    thread t = new thread(new threadstart(delegate()

    region[ new thread ].

    Functions that run with a new thread.

    public void runbynewth()

    text;#endregion

    This kind of thread delegation also has certain limitations, such as when the main thread is busy, the delegation will be postponed, that is, the time set in the delegation may not be very accurate.

  2. Anonymous users2024-02-09

    The latest version. There are async and await, which can easily solve this problem.

    Old. net can try to access the main thread's controls with an invoke delegate:

    Suppose the label name is label1.

    First, create a new delegate:

    private delegate void modlabeltext(string msg);

    Then build a method to have the main thread modify the label:

    private void modlabeltext(string message)

    if (modlabeltext c = new modlabeltext(modlabeltext);

    new object

    message;

    Next, build a method for new threads to use:

    private void label1sleep()

    Let this subthread rest for 1 second.

    todo other operations.

    modlabeltext("You're good too");

    Finally, you can change the text first, and then wait a second to see, is it changed?

    private void button1_click(object sender, eventargs e)

    Hello";td = new ;;

  3. Anonymous users2024-02-08

    = "a";

    Or; = "b";

    The test has passed.

    The reason is that the program has not had time to change the text attribute of lb and has started sleeping, and after sleep is over, b is directly assigned, so what you see is b, so add a sentence to update the control or redraw the control and start sleep after the update or redraw is completed, you can achieve the result you need.

  4. Anonymous users2024-02-07

    What do you use without timer? You are just coming up with 10,000 ways to still operate threads to implement your functions, timer is a good control, threads are independent, resource sharing! Don't bother with it.

  5. Anonymous users2024-02-06

    An error is reported due to a usage error. The solution and procedure are as follows:

    1. Preferred, open the compiler, and then type edit in the command line to open it, as shown in the following figure.

    2. Secondly, after completing the above steps, enter function to indicate that the file is a function file, as shown in the image below.

    3. Next, if any return value is entered to the left of the equal sign, use square brackets to indicate multiple return values, as shown in the image below.

    4. Then, to the right of the equal sign is the function name plus parentheses, and the parentheses are the parameters, as shown in the following figure.

    5. Subsequently, after completing the above steps, use the comment, the first line of the comment is to explain the function of the function as shown in the following image.

    6. Then, after completing the above steps, pass the coordinates of the two points, then calculate the distance between the two points, and pass it to the return value y, as shown in the figure below.

    7. Finally, after completing the above steps, save the file, and the file name and function name remain unchanged when saving, as shown in the following figure. In this way, the problem is solved.

  6. Anonymous users2024-02-05

    The two are completely different :

    1. Syntax error: Syntax error refers to ** error, which is a compilation error, that is, an error that can be identified at the time of development. ** with compilability errors in C will not compile at all, i.e., you will not be able to build an executable program.

    2. Abnormal error: Abnormal error is a runtime error, that is, an error caused by triggering a certain situation during the running of the program, which cannot be found at the time of compilation, and can only be found at the time of running. For example:

    a)string s = null; ',');In this case, a nullreference exception will be reported, which tells you that empty objects cannot call the split method. However, at compile time, you don't know whether s is null or not (after all, few people actually write these two sentences together, maybe s is not null halfway through), so there is no error during compilation, and only when it is executed.

Related questions
4 answers2024-05-13

Is it called 0th or 1st position next to s2? This is better explained. >>>More

4 answers2024-05-13

The meaning of the title of the first question is not too clear (since they do it in turns and there are no special conditions, don't they all take the same amount of time no matter what they do?). )。 >>>More

7 answers2024-05-13

#include

void main() >>>More

33 answers2024-05-13

Your marriage is a bit like me, my husband and I are also inter-provincial marriages, I am from Guilin, and my husband is from Shaanxi. My husband also went to our house, but we also have to take care of his parents in Shaanxi. It's just that we didn't buy a house, and now the house in Guilin was built by my parents, so I didn't have the problem of buying a house at that time. >>>More

7 answers2024-05-13

I think lz just wants to print out the address of a and the address of a+1 Here, a is the starting address of the array, so &a takes the address with a as a variable, that is, the address that stores the address of the array, but if (a+1) is addressed, it is not right, because (a+1) is not a defined variable here, but the value of a temporary variable, it is only equal to the value of the next address of the starting address of the array, not a variable that stores the value, and it is not right to take the address. >>>More