计时器运行C#时无法单击按钮

时间:2018-11-06 18:43:36

标签: c# button timer wpf-controls windows-forms-designer

我已经申请了一个带有退出按钮的字幕文本。当禁用计时器时,该按钮可以正常工作,但是一旦启用计时器,则无法单击该按钮。 谁能帮帮我吗?我尝试过在线研究,但似乎没有答案,谢谢! :)

这是我拥有的代码

        11-06 13:31:37.259 1652-1652/artiq.com.shazam I/TensorFlowInferenceInterface: Successfully loaded model from 'file:///android_asset/tz6-s-stitch-sblur-lowtv-gen.pb'
        11-06 13:31:37.911 1652-1821/artiq.com.shazam A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 1821 (AsyncTask #3)

                                                              [ 11-06 13:31:37.911   118:  118 W/         ]
                                                              debuggerd: handling request: pid=1652 uid=10075 gid=10075 tid=1821
        11-06 13:31:37.994 1825-1825/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
        11-06 13:31:37.994 1825-1825/? A/DEBUG: Build fingerprint: 'Android/vbox86p/vbox86p:7.1.1/NMF26Q/genymo03202243:userdebug/test-keys'
        11-06 13:31:37.994 1825-1825/? A/DEBUG: Revision: '0'
        11-06 13:31:37.994 1825-1825/? A/DEBUG: ABI: 'x86'
        11-06 13:31:37.994 1825-1825/? A/DEBUG: pid: 1652, tid: 1821, name: AsyncTask #3  >>> artiq.com.shazam <<<
        11-06 13:31:37.996 1825-1825/? A/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
        11-06 13:31:37.996 1825-1825/? A/DEBUG:     eax 00000000  ebx 00000674  ecx 0000071d  edx 00000006
        11-06 13:31:37.996 1825-1825/? A/DEBUG:     esi b99e3978  edi b99e3920
        11-06 13:31:37.996 1825-1825/? A/DEBUG:     xcs 00000023  xds 0000002b  xes 0000002b  xfs 0000006b  xss 0000002b
        11-06 13:31:37.996 1825-1825/? A/DEBUG:     eip f2d96bb9  ebp b99df9e8  esp b99df98c  flags 00000296
        11-06 13:31:38.035 1825-1825/? A/DEBUG: backtrace:
        11-06 13:31:38.084 1825-1825/? A/DEBUG:     #00 pc 00000bb9  [vdso:f2d96000] (__kernel_vsyscall+9)
        11-06 13:31:38.084 1825-1825/? A/DEBUG:     #01 pc 0007a30c  /system/lib/libc.so (tgkill+28)
        11-06 13:31:38.084 1825-1825/? A/DEBUG:     #02 pc 00075b55  /system/lib/libc.so (pthread_kill+85)
        11-06 13:31:38.084 1825-1825/? A/DEBUG:     #03 pc 0002786a  /system/lib/libc.so (raise+42)
        11-06 13:31:38.084 1825-1825/? A/DEBUG:     #04 pc 0001ee46  /system/lib/libc.so (abort+86)
        11-06 13:31:38.084 1825-1825/? A/DEBUG:     #05 pc 012e2114  /data/app/artiq.com.shazam-1/lib/x86/libtensorflow_inference.so
        11-06 13:31:38.084 1825-1825/? A/DEBUG:     #06 pc 012af3f8  /data/app/artiq.com.shazam-1/lib/x86/libtensorflow_inference.so
        11-06 13:31:38.084 1825-1825/? A/DEBUG:     #07 pc 012af46f  /data/app/artiq.com.shazam-1/lib/x86/libtensorflow_inference.so
        11-06 13:31:38.084 1825-1825/? A/DEBUG:     #08 pc 012af5a3  /data/app/artiq.com.shazam-1/lib/x86/libtensorflow_inference.so
        11-06 13:31:38.084 1825-1825/? A/DEBUG:     #09 pc 012afaf2  /data/app/artiq.com.shazam-1/lib/x86/libtensorflow_inference.so
        11-06 13:31:38.084 1825-1825/? A/DEBUG:     #10 pc 0057e9ec  /data/app/artiq.com.shazam-1/lib/x86/libtensorflow_inference.so
        11-06 13:31:38.084 1825-1825/? A/DEBUG:     #11 pc 0057512c  /data/app/artiq.com.shazam-1/lib/x86/libtensorflow_inference.so
        11-06 13:31:38.084 1825-1825/? A/DEBUG:     #12 pc 00573d7c  /data/app/artiq.com.shazam-1/lib/x86/libtensorflow_inference.so
        11-06 13:31:38.084 1825-1825/? A/DEBUG:     #13 pc 00573049  /data/app/artiq.com.shazam-1/lib/x86/libtensorflow_inference.so
        11-06 13:31:38.084 1825-1825/? A/DEBUG:     #14 pc 005bc4f8  /data/app/artiq.com.shazam-1/lib/x86/libtensorflow_inference.so
        11-06 13:31:38.084 1825-1825/? A/DEBUG:     #15 pc 005b9ef1  /data/app/artiq.com.shazam-1/lib/x86/libtensorflow_inference.so
        11-06 13:31:38.084 1825-1825/? A/DEBUG:     #16 pc 005bb65e  /data/app/artiq.com.shazam-1/lib/x86/libtensorflow_inference.so
        11-06 13:31:38.084 1825-1825/? A/DEBUG:     #17 pc 010075c4  /data/app/artiq.com.shazam-1/lib/x86/libtensorflow_inference.so
        11-06 13:31:38.084 1825-1825/? A/DEBUG:     #18 pc 01028f86  /data/app/artiq.com.shazam-1/lib/x86/libtensorflow_inference.so
        11-06 13:31:38.084 1825-1825/? A/DEBUG:     #19 pc 010295f1  /data/app/artiq.com.shazam-1/lib/x86/libtensorflow_inference.so
        11-06 13:31:38.084 1825-1825/? A/DEBUG:     #20 pc 0101ae48  /data/app/artiq.com.shazam-1/lib/x86/libtensorflow_inference.so
        11-06 13:31:38.084 1825-1825/? A/DEBUG:     #21 pc 0102778a  /data/app/artiq.com.shazam-1/lib/x86/libtensorflow_inference.so
        11-06 13:31:38.084 1825-1825/? A/DEBUG:     #22 pc 01026713  /data/app/artiq.com.shazam-1/lib/x86/libtensorflow_inference.so
        11-06 13:31:38.084 1825-1825/? A/DEBUG:     #23 pc 0100e23e  /data/app/artiq.com.shazam-1/lib/x86/libtensorflow_inference.so
        11-06 13:31:38.084 1825-1825/? A/DEBUG:     #24 pc 0100f2bb  /data/app/artiq.com.shazam-1/lib/x86/libtensorflow_inference.so
        11-06 13:31:38.084 1825-1825/? A/DEBUG:     #25 pc 002777a5  /data/app/artiq.com.shazam-1/lib/x86/libtensorflow_inference.so
        11-06 13:31:38.084 1825-1825/? A/DEBUG:     #26 pc 0027c9e3  /data/app/artiq.com.shazam-1/lib/x86/libtensorflow_inference.so
        11-06 13:31:38.084 1825-1825/? A/DEBUG:     #27 pc 00271403  /data/app/artiq.com.shazam-1/lib/x86/libtensorflow_inference.so (Java_org_tensorflow_Session_run+1091)
        11-06 13:31:38.084 1825-1825/? A/DEBUG:     #28 pc 0010f2d7  /system/lib/libart.so (art_quick_generic_jni_trampoline+71)
        11-06 13:31:38.085 1825-1825/? A/DEBUG:     #29 pc 00109432  /system/lib/libart.so (art_quick_invoke_static_stub+418)
        11-06 13:31:38.085 1825-1825/? A/DEBUG:     #30 pc 00112de9  /system/lib/libart.so (_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+313)
        11-06 13:31:38.085 1825-1825/? A/DEBUG:     #31 pc 0031d646  /system/lib/libart.so (_ZN3art11interpreter34ArtInterpreterToCompiledCodeBridgeEPNS_6ThreadEPNS_9ArtMethodEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+294)
        11-06 13:31:38.085 1825-1825/? A/DEBUG:     #32 pc 003166e0  /system/lib/libart.so (_ZN3art11interpreter6DoCallILb1ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+480)
        11-06 13:31:38.085 1825-1825/? A/DEBUG:     #33 pc 0067eade  /system/lib/libart.so (MterpInvokeStaticRange+414)
        11-06 13:31:38.085 1825-1825/? A/DEBUG:     #34 pc 000fb9a1  /system/lib/libart.so (artMterpAsmInstructionStart+15265)
        11-06 13:31:38.085 1825-1825/? A/DEBUG:     #35 pc 002e5f48  /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+488)
        11-06 13:31:38.085 1825-1825/? A/DEBUG:     #36 pc 002ed790  /system/lib/libart.so (_ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+192)
        11-06 13:31:38.085 1825-1825/? A/DEBUG:     #37 pc 003166c2  /system/lib/libart.so (_ZN3art11interpreter6DoCallILb1ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+450)
        11-06 13:31:38.085 1825-1825/? A/DEBUG:     #38 pc 0067eade  /system/lib/libart.so (MterpInvokeStaticRange+414)
        11-06 13:31:38.085 1825-1825/? A/DEBUG:     #39 pc 000fb9a1  /system/lib/libart.so (artMterpAsmInstructionStart+15265)
        11-06 13:31:38.085 1825-1825/? A/DEBUG:     #40 pc 002e5f48  /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+488)
        11-06 13:31:38.086 1825-1825/? A/DEBUG:     #41 pc 002ed790  /system/lib/libart.so (_ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+192)
        11-06 13:31:38.086 1825-1825/? A/DEBUG:     #42 pc 003154cb  /system/lib/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+587)
        11-06 13:31:38.086 1825-1825/? A/DEBUG:     #43 pc 0067c330  /system/lib/libart.so (MterpInvokeDirect+464)
        11-06 13:31:38.086 1825-1825/? A/DEBUG:     #44 pc 000fb621  /system/lib/libart.so (artMterpAsmInstructionStart+14369)
        11-06 13:31:38.086 1825-1825/? A/DEBUG:     #45 pc 002e5f48  /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+488)
        11-06 13:31:38.086 1825-1825/? A/DEBUG:     #46 pc 002ed790  /system/lib/libart.so (_ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+192)
        11-06 13:31:38.086 1825-1825/? A/DEBUG:     #47 pc 003154cb  /system/lib/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+587)
        11-06 13:31:38.086 1825-1825/? A/DEBUG:     #48 pc 0067ab5e  /system/lib/libart.so (MterpInvokeVirtual+718)
        11-06 13:31:38.086 1825-1825/? A/DEBUG:     #49 pc 000fb521  /system/lib/libart.so (artMterpAsmInstructionStart+14113)
        11-06 13:31:38.086 1825-1825/? A/DEBUG:     #50 pc 002e5f48  /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+488)
        11-06 13:31:38.086 1825-1825/? A/DEBUG:     #51 pc 002ed790  /system/lib/libart.so (_ZN3art11interpreter33ArtInterpreterToInterpreterBridgeEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameEPNS_6JValueE+192)
        11-06 13:31:38.086 1825-1825/? A/DEBUG:     #52 pc 003154cb  /system/lib/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+587)
        11-06 13:31:38.086 1825-1825/? A/DEBUG:     #53 pc 0067ab5e  /system/lib/libart.so (MterpInvokeVirtual+718)
        11-06 13:31:38.086 1825-1825/? A/DEBUG:     #54 pc 000fb521  /system/lib/libart.so (artMterpAsmInstructionStart+14113)
        11-06 13:31:38.086 1825-1825/? A/DEBUG:     #55 pc 002e5f48  /system/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadEPKNS_7DexFile8CodeItemERNS_11ShadowFrameENS_6JValueEb+488)
        11-06 13:31:38.086 1825-1825/? A/DEBUG:     #56 pc 002ed6a0  /system/lib/libart.so (_ZN3art11interpreter30EnterInterpreterFromEntryPointEPNS_6ThreadEPKNS_7DexFile8CodeItemEPNS_11ShadowFrameE+176)
        11-06 13:31:38.086 1825-1825/? A/DEBUG:     #57 pc 0066d199  /system/lib/libart.so (artQuickToInterpreterBridge+1049)
        11-06 13:31:38.087 1825-1825/? A/DEBUG:     #58 pc 0010f39d  /system/lib/libart.so (art_quick_to_interpreter_bridge+77)
        11-06 13:31:38.087 1825-1825/? A/DEBUG:     #59 pc 0000263d  /dev/ashmem/dalvik-jit-code-cache (deleted)
        11-06 13:31:39.123 1652-1652/artiq.com.shazam I/Choreographer: Skipped 74 frames!  The application may be doing too much work on its main thread.
        11-06 13:31:39.124 561-1830/system_process W/ActivityManager:   Force finishing activity artiq.com.shazam/.EditImageActivity

1 个答案:

答案 0 :(得分:1)

使用DispatchTimer,它将在单独的线程上运行,并且事件将在UI线程上触发,因此您将能够修改UI

private DispatcherTimer dispatcherTimer;


public FORM_ENTRY()
{
    InitializeComponent();
    LabelWelcome.Text = "Welcome! Welkom! Selamat Datang! Wilkommen!";
    LabelCheckedIn.Visible = false;
    LabelEnjoy.Visible = false;

    // Initialize Dispatcher
    dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
    dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
    // Five seconds delay
    dispatcherTimer.Interval = new TimeSpan(0, 0, 5);
    dispatcherTimer.Start();
}

private void dispatcherTimer_Tick(object sender, EventArgs e)
{
    System.Text.StringBuilder sb = new System.Text.StringBuilder(LabelWelcome.Text);        
    char ch = sb[sb.Length - 1];
    sb.Remove(sb.Length - 1, 1);
    sb.Insert(0, ch);
    LabelWelcome.Text = sb.ToString();
}

private void ButtonExit_Click(object sender, EventArgs e)
{
    this.Close();
}