Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8626231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:58:30+00:00 2026-06-12T07:58:30+00:00

i have recently started working on C# and i am very amateur at it

  • 0

i have recently started working on C# and i am very amateur at it
please any help in the problem decirbed below will b very helpful for me

What i wanted to do is have an access of video_panel in event handler as-well
but right now i dont know how to do that
i tried to declare media element global and set its value to video_panel
but still no use
what should i do
what i want to is instead of displaying a message pause a video currently playing

namespace Play_pause
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{

  static   int index = 0;
  static  System.Timers.Timer aTimer = new System.Timers.Timer();
    public MainWindow()
    {
        InitializeComponent();
       video_panel.Play();

        // Hook up the Elapsed event for the timer.
        aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);

        // Set the Interval to 2 seconds (2000 milliseconds).
        aTimer.Interval = 2000;

        aTimer.Start();




    }

    private static void OnTimedEvent(object source, ElapsedEventArgs e)
    {



        index++;
        if (index %2==0)
        {
            MessageBox.Show("Can't access media element in the event handler/n how to    
            set it global?");




        }

    }    
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T07:58:31+00:00Added an answer on June 12, 2026 at 7:58 am

    Read the answers here again, they show how to make a variable global.

    But this wont solve your problem. Since your OnTimedEvent-method is static, you can access only static variables.
    I dont think your OnTimedEvent should be static, so try to remove the word “static” and now you can acess global variables (e.g. your video_panel).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a very elementary I realize, I have recently started working with asp.net
I'm very used to working in WPF, but I have recently started building websites
I have recently started working on a very large C++ project that, after completing
I have recently started working on an app which has both Java and native
I'm a junior developer and recently started working for a very small office where
I have started working with C++ recently and am not comfortable with Visual Studio
I have recently started working as a web developer. I work with ASP .NET
I have recently started working on a web application at a new company and
I have recently just started working with Lucene (specifically, Lucene.Net) and have successfully created
So I've recently started working with ASP .NET but I am very familiar with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.