עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

שאלה לגבי פונקציות ומשתנים ב- C#

Featured Replies

פורסם

שלום,

 

יש לי THREAD נפרד שמפעיל התראה קולית כל עוד ערך BOOLEAN TRUE. כאשר אני משנה את הערך של המשתנה לfalse בתוכנית הראשית אז המשתנה לא מתעדכן ב- THREAD.

 

איך מעדכנים משתנה ב- THREAD בזמן הריצה שלו. ז"א אומרת צריך ליצור EVENT שיתריע על השינוי אבל איך מעדכנים את ה- THREAD?

 

תודה לעונים

פורסם

אין EVENT כזה אבל לא צריכה להיות שום בעיה להחזיק אובייקט משותף שגם התוכנית הראשית וגם ה-thread יכולים לגשת אליו.

פורסם
  • מחבר

המשתנה הבולאני מוגדר בתחילת התוכנית ועדיין זה לא עוזר שהוא משתנה

נערך על-ידי harap

פורסם

ב-C#  סוגים בסיסיים של המערכת הם משהו קצת מיוחד (בוליאני הוא גם immutable) לא סתם אמרתי אובייקט.

 

יעזור אם תביא חתיכת קוד רלוונטית

פורסם
  • מחבר
            while (Alarm)
            {
                Thread t = new Thread(alarmON);
                t.Start();
                if (showMassge)
                {
                    showMassge = false;
                    DialogResult dr = MessageBox.Show("caution! you over the yellow limit", "YELLOW WARNNING", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    if (dr.Equals(DialogResult.OK))
                    {
                        Alarm = false;
                        t.Abort();
                        sp.Pause();
                    }
                }

            }
          
            
        }

        private void alarmON()
        {
            
                while (this.Alarm)
                {
                   
                    this.Invoke(new Action(() =>
                    {
                        sp.SpeakAsync("caution! you over the yellow limit");

                    }));

                }
                   
        }

 

נערך על-ידי harap

פורסם
  • מחבר

איך אני מעדכן את ה- THREAD שנקרא alarmON  שהמשתנה הבוליאני Alarm השתנה ל - false ושיפסיק להשמיע התראה

פורסם

אני לא רואה את ההגדרה של Alarm, תנסה להגדיר אותו כ-volatile כדי שהקומפיילר ידע שניגשים אליו מכמה threads.

פורסם
  • מחבר

volatile  boolean Alarm? ככה להגדיר?

 

גם לא עובד ככה...עכשיו בדקתי

נערך על-ידי harap
עדכון

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.