473,624 Members | 2,117 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using ISynchronizeInv oke

Hi,
I am creating a multithreaded server application in
Managed C++. Each client that connects to the server will
be running on their own thread to process their input.
They all need to share one instance of a class running on
the main thread. From my understanding, if multiple
threads invoke a function in this object(on the main
thread) using a delegate, there could be problems. I was
trying to figure out how to invoke the functions using
ISynchronizeInv oke, but I have not been able to find a
good example of how to use it. Can anyone point me in the
right direction?

Thanks,
Tim
Nov 16 '05 #1
1 5006
Hi Tim,
I am creating a multithreaded server application in
Managed C++. Each client that connects to the server will
be running on their own thread to process their input.
They all need to share one instance of a class running on
the main thread. From my understanding, if multiple
threads invoke a function in this object(on the main
thread) using a delegate, there could be problems.


There shouldn't be any, as far as I know, as long as the object itself
supports concurrent invocation correctly by ensuring it's own internal state
remains consistent despite being called from multiple threads.

The ISynchronizedIn voke thingie is mostly done to support Winforms, where
calls to UI widgets need to be always done from the same thread, because
they are subject to the old thread-specific issues that plague the win32
user interface event model from the beginning of time.

--
Tomas Restrepo
to****@mvps.org
Nov 16 '05 #2

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

Similar topics

9
2239
by: GM | last post by:
Hi, My application has a need to cache a number of shared reference lists containing basic business objects. In order to improve performance these lists are fetched and updated in the background. When a UI is required to display one of these reference lists it requests it by name from the cache. If the list already exists in the cache it is returned to the caller otherwise a brand new empty one is created and returned. This new empty...
2
5906
by: rawCoder | last post by:
Hi All, I have a *.cer file, a public key of some one and I want to encrypt some thing using this public key. Can someone point me to a sample code for Encrypting some file using X509Certificate ( *.cer file ) so that it can be used to email as attachment. The real part is Encrypting using X509Certificate and CryptoServiceProvider.
11
13556
by: JPRoot | last post by:
Hi I wish to set/get a property using System.ComponentModel.ISynchronizeInvoke.Invoke but I cannot find the exact syntax.. Any clue how to do this (right now I am making GetEnabled/SetEnabled methods when I wish to get/set Form.Enabled property. Thank JPRoo
0
2494
by: Wavemaker | last post by:
One of the things I've struggled with from time to time is handling events raised on different threads. For example, an object could be listening to events from one or more objects running in different threads besides itself. There is a concern for thread safety. There are various ways of dealing with this. One way is to make the class thread safe by putting in locks. But another way is to stream the events from the various threads into a...
1
3079
by: Thai Mai Shu | last post by:
What is wrong with my call below. If I change the delegate and the CallBackComplete function to not take in parameters then the .Invoke call works fine. As soon as I put the parameters back I get "Parameter count mismatch." error. Am I supposed to implement ISynchronizeInvoke in order to call .Invoke? If so, why does it work when the method i am trying to invoke has no parameters. Private Delegate Sub CallbackCompleteDelegate(ByVal...
4
4019
by: jherl | last post by:
I am getting an "Object reference not set to an instance of an object" when I try to execute the Invoke method. I have it set up as follows: --- Private _syncObject As System.ComponentModel.ISynchronizeInvoke .. .. .. Dim args(0) As Object Dim d As New RaiseReceiveEvent(AddressOf OnReceive) ..
3
6654
by: jtagpgmr | last post by:
I need help coming up with a way to create a c# program to help me Telnet to a hostIP.. Any suggestions.. or a way to start..
23
2627
by: Thomas Due | last post by:
Hi, I have a class which monitors a TCP socket. This will on occasion raise an event which can be handled by a GUI. Now, I am aware of the if(InvokeRequire) { EventHandler d = new EventHandler(); Invoke(d, new object{sender, e}); } else {
3
8258
by: JDeats | last post by:
I have some .NET 1.1 code that utilizes this technique for encrypting and decrypting a file. http://support.microsoft.com/kb/307010 In .NET 2.0 this approach is not fully supported (a .NET 2.0 build with these methods, will appear to encrypt and decrypt, but the resulting decrypted file will be corrupted. I tried encrypting a .bmp file and then decrypting, the resulting decrypted file under .NET 2.0 is garbage, the .NET 1.1 build works...
0
8680
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8624
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8336
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
8478
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...
1
6111
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
4082
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
4176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1786
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1485
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.