473,887 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DynamicInvoke and simply calling the event


hi all!

<i'm fairly new to csharp (and dotnet) and is particularly
confused with delegates and events.. so forgive me if im a bit dense..>

Is there any major concern that i need to think about when
triggerring an event or a delegate using DynamicInvoke()
versus simply calling the event..

MyEvent.Dynamic Invoke(sender, args);
//versus this:
MyEvent(sender, args);

I worry about this, since im trying to create an "EventPool"
collection. The events/delegates are dynamically created
(published) in a hash table. And other classes trigger
these events through the EventPool class.
Triggering an event calls either one of the statements above.

...and do you have any suggestions regarding the
creation of an EventPool. Im still not sure how to publish
unique events. Right now, i have two options:
1. using a string name that is specified by string
literals in both the publisher and the subscriber
(two different classes from possibly two different assemblies).
2. create a sort of utility class (sealed and non-instantiatable) ..
with static declarations for the delegates.. then i use
the ToString() function of those delegates to determine
a event name (the publisher & subscribers need a reference
to this class).

i wanted to sort of de-couple the publisher & subscriber <sort of>
this would be easier in C++ since we can have header files
with #defines in it.. that both the publisher & the subsriber
would only need to include.

am i even going in the right direction?

pls help.
thank you.

--
It is only through the heart that one can see rightly. (The Little Prince)

MickeyMicks
Oct 6 '06 #1
0 1262

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
8190
by: Arif Khan | last post by:
How can I pass, by ref or out parameter values when calling DynamicInvoke Method. e.g. Here is my Delegate: public delegate int BinaryOp(int x, int y, out double z, ref bool overflow); Here is how I am creating a delegate object for "Subtract" method. BinaryOp op2 = (BinaryOp) Delegate.CreateDelegate(dt, tt,"Subtract"); Here is how I am creating parameters object. Notice t and ret are
12
6627
by: CM | last post by:
Hi, I used to use the following code to play sound in VB6: Public Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" _ (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long call sndPlaySound32("c:\WinNt\Media\ding.wav", 0)
12
7105
by: Ron | last post by:
Greetings, I am trying to understand the rational for Raising Events instead of just calling a sub. Could someone explain the difference between the following 2 scenarios? Why would I want to raise an event instead of just calling the sub? Scenario1 -- Using Events ------------------------------------------------------ Public Class Form1
3
19291
by: Amir Shitrit | last post by:
Hi to all. Whats the difference between DynamicInvoke and Invoke methods of the Delegate class? Thanks in advance.
3
4257
by: Jason | last post by:
I have an ASP.NET application in which I would like to call my button click event (imgSubmitSearch_Click) on the page load if certain criteria are met. Is this possible? What is the correct syntax to be able to programmatically have my imgSubmitSearch button clicked? I tried the obvious, Call imgSubmitSearch, but intellisense doesn't like that due to the sender / e arguments. Private Sub imgSubmitSearch_Click(ByVal sender As...
1
3007
by: =?Utf-8?B?aGVyYmVydA==?= | last post by:
Jon Skeet wrote in the .NET general newsgroup 11/17/2005: "The difference between Invoke and DynamicInvoke is that the parameters to Invoke depend on the delegate itself - the method has the same signature as the delegate. DynamicInvoke has a "fixed" signature, and it dynamically calls Invoke with the appropriate parameters." So far I have seen DynamicInvoke only used in conjunction with generics event arguments. Is there any other...
0
1799
by: flyingchen | last post by:
using System; using System.Windows.Forms; using System.Threading; using System.ComponentModel; namespace ProgressControl.Core { public delegate object Execute(params object args); public class ProgressController
1
2723
by: Terry Olsen | last post by:
I'm using the SciLexer.dll to write a code editor for an in-house scripting language. I have the editor window up on a form but I need to use it's API. I've used the following commands to load the dll: Private scihWnd As Integer 'Scintilla's hWnd Private SciFunc As Integer 'Scintilla's Main Function Call Private sciptr As Integer 'Scintilla's Direct Pointer Private scihmod As Integer 'Scintilla's hMod scihmod =...
5
9740
by: puzzlecracker | last post by:
I've just discovered DynamicInvoke methods while reading Jon's threading article. And my question is how it's different from a regular invoke method? In this method: /// <summary> /// Invokes the wrapped delegate synchronously /// </summary> static void InvokeWrappedDelegate (Delegate d, object args)
0
9799
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10875
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10432
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9593
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7988
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5809
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6011
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4632
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4238
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.