Hi,
I am having a scenario, in which i have multiple delegates attached to the event (multicast delegate).
What could be the sequence of calling these methods/delegates (if any) ???
In case one of the method attached with the delegate throws the exception.
Will the event stop processing further...???
Will the rest of the methods att...
I have a button class - when the button is clicked, the playFile method of the MyAudio class is called. So my question is, its trivial to call the playFile method from the button class, but how do I call the method displayStopButton from the initiator class?
button class
- (void)myButtonClicked: (id)sender
{
[MyAudio playFile];
}
...
Currently "Avoid checking for null event handlers" is at the top of the answers to the post titled Hidden Features of C# and it contains severely misleading information.
While I understand that Stack Overflow is a "democracy" and the answer rose to the top by virtue of public voting, I feel that a lot of people that up-voted the answer ...
Note: this was inspired by WebBrowser Event Properties?
Why am I able to access the MulticastDelegate members of an event within the type that declares the event but not outside of it?
For instance:
using System;
class Bar
{
public static event Action evt;
}
class Program
{
static event Action foo;
static Bar bar;
...
I have an NSTokenField in a window. I am using it to store tags related to a Core Data object. Right now I have it set up such that I can add tags to the objects, but I cannot delete them. I need a delegate method on the NSTokenField that can let me know when the user has moved the focus out of the NSTokenField. Since NSTokenField is...
I have some code,
int count = 0;
list.ForEach(i => i.SomeFunction(count++));
This seems to not increment count. Is count passed by value here? Is there any difference if I use the {} in the lambda?
int count = 0;
list.ForEach(i =>
{
i.SomeFunction(count++);
});
Update 1
Sorry, my mis...
I'm still new to delegates and I've been playing with the Delegate-based Data Access Layer described in Steven John Metsker's "Design Patterns in C#" book (an excellent read!). It defines the data access delegate like this:
public delegate object BorrowReader(IDataReader reader);
The result of using this is code that looks like one of...
This is the scenario. I am using scsf to develop my application. I am using asynchronous delegates to keep my UI responsible. I have a CAB service which is in charge of notifying exceptions to the final users in a friendly manner (message box).
I will show you an hypothetical example which ilustrates the actual issue (I will reduce the...
We have been going through a big memory leak analysis and have found one of the contributing factors has been the non removal of delegates on events causing objects to not be GCed quickly enough (or sometimes forever).
Would anyone have any ideas as to how to write a rule in FXCop to ensure that we have delegates are removed from handl...
No matter how I try, I cannot mimic the clean syntax of Rhino Mocks, without declaring a delegate.
Example:
Expect.Call(service.HelloWorld("Thanks"))
Do you have any idea on how to do this?
Thanks.
...
Hello,
C# 2008 SP1
The function below will be called from another thread. So the control themselves will have to be invoked so that the correct thread that created them can change the properties.
However, as I have many controls that need to be updated. I don't really want to write all those delegates for each one. I have done one bel...
I have a common comms library that i have written to communicate with our hardware over TCP/IP
The common library allows both the clients application and our engineer tool to share common code.
The common library runs threads that need to return data back to forms.
I have some working code but I feel that there must be an easier way ...
Is there any way that I can create a new delegate type based on an existing one? In my case, I'd like to create a delegate MyMouseEventDelegate which would have the same functionality as EventHandler<MouseEventArgs>.
Why do I want this? To take advantage of compile-time type-checking, of course! This way, I can have two different delega...
See the four lines in the Go() method below:
delegate void Action<T>(T arg);
delegate void Action();
void DoSomething<T>(Action<T> action)
{
//...
}
void DoSomething(Action action)
{
//...
}
void MyAction<T>(T arg)
{
//...
}
void MyAction()
{
//...
}
void Go<T>()
{
DoSomething<T>(MyAction<T>); // throws compiler...
Hi,
I have a C# Windows service application that passes a callback function pointer to a C++ dll. I have defined both the function pointer at the C# side and C++ side to be __stdcall type. Everything works fine till the callback is triggered by the C++ dll and throws an Unhandled Exception Access Violation in 0x04cb0e. The debug stops in...
I fail to see the reason why this code fails (Error binding to target method.)
public interface Interface
{}
public class Implementation : Interface
{}
public class Program
{
public static void Main()
{
Invoke();
}
public Interface SomeMethod(object arg)
{
return...
Really pulling my hair out with this one...
I have a C# project with an interface defined as:
/* Externally Accessible API */
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface ISerial
{
[DispId(1)]
bool Startup();
[DispId(2)]
bool Shutdown();
[DispId(3)]
bool UserInput_FloorButton(int flo...
My understanding is that protocols are like interfaces in other languages -- they declare expected methods -- while categories allow you to add new methods to existing types (perhaps even types you don't own.)
Why, then, does the iPhone SDK sometimes use categories for declaring delegate types? Normally I would expect all delegates to b...
I'm pretty sure that I've taken all steps to correctly set my status bar to hidden. I did this in both the info.plist file (setting a UIStatusBarHidden to a boolean TRUE) as well as in the applicationDidFinishLaunching method in the Application Delegate using:
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];
An...
I built a Testbox to learn something about threading in windows form applications.
Silverlight and Java are providing the Dispatcher, which really helps when updating
GUI Elements.
Code Samples:
Declaration Class Delegate
public delegate void d_SingleString(string newText);
Create Thread
_thread_active = true;
Thread...