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

  • Home
  • SEARCH
  • 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 7883065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:26:07+00:00 2026-06-03T04:26:07+00:00

Can i raise a static event thread safe? (i am not entirely sure what

  • 0

Can i raise a static event thread safe? (i am not entirely sure what that even means.)
The whole thing is part of an audio application, so i have (at least) the audio processing thread and the UI thread.

The RaisePrintEvent gets invoked from unmanaged C code which processes the audio and other messages. The call to raise the event can happen from the audio processing thread and the UI thread.

public static event ProcessPrint Print = delegate {};

private static void RaisePrintEvent(string e)
{
    Print(e);
}

How can i make sure, that the event call is synchronized? Or maybe just invoked in the main thread..

EDIT: read on here for a smart solution.

  • 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-03T04:26:08+00:00Added an answer on June 3, 2026 at 4:26 am

    You must ensure that the UI operations are all executed on the main/UI thread.

    Best way would be to queue the messages into some form of queue from the audio thread and dequeue and display it from main UI thread, from Forms.Timer event, for example.

    Invoke() won’t get you far because your timing in the audio processing will be broken. If you try it, and you are doing something with your GUI, you’ll probably get jerking in the audio, since Invoke()-ing something on other thread will BLOCK until other thread process the window message that is used to do Invoke ‘under the hood’.

    If you don’t understand some or all of the above, just try to use queue for the messages.

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

Sidebar

Related Questions

I know that it's a subject that can raise a lot of debate, but
How can I raise an event while clicking a textbox? I'm having trouble finding
We're all familiar with the horror that is C# event declaration. To ensure thread-safety,
the following code raises the aforementioned error, how can I fix that? require 'mechanize'
I'm working on custom control that I can use for interactions within my app
Can you help explain how multiple threads access static methods? Are multiple threads able
There is a problem with standard System.Timers.Timer behaviour. The timer raise Elapsed event with
I have a thread that runs querying a DB and returning some values. If
It's not the first time I've created a Custom Event in C#. It boggles
I have tried everything, even uninstalling asp.net mvc3, and I can't get HandleError global

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.