473,692 Members | 2,160 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

IPC-Remoting: Threading issue in MDI-application

Hello,

I have an Mdi-application which also is a remoting-server (Ipc).
Several instances can co-exist on the same machine.

I have a small app (search-engine) (remoting-client) which calls a sub on
the MDI (specific instance) thus retrieving eg the data of a certain customer.
If the customer childform is already instanciated, there is no problem.
If the destination-childform is not yet open, it will be opened like this:

' Create an instance of the form
If Childform.frmIn stallations Is Nothing Then
Childform.frmIn stallations = New frmInstallation s
With Childform.frmIn stallations
.MdiParent = MDI ' This variable creates a threading-issue
.Show(Commands. ReadAllowed("In stallationsOver view"))
End With
Else

It is the assignment of the MdiParent which poses the problem.
'MDI' is a variable which references the instance of the Main (mdi) Form
(frmMain).
The generated exception is this: "Cross-thread operation not valid: Control
'frmMain' accessed from a thread other than the thread it was created on."

How can I solve this threading-issue?

TIA,
Michael
Jan 2 '08 #1
2 1828
=?Utf-8?B?TWljaGFlbCB NYWVz?= <mi**********@c ommunity.nospam wrote in
news:66******** *************** ***********@mic rosoft.com:
It is the assignment of the MdiParent which poses the problem.
'MDI' is a variable which references the instance of the Main (mdi)
Form (frmMain).
The generated exception is this: "Cross-thread operation not valid:
Control 'frmMain' accessed from a thread other than the thread it was
created on."

How can I solve this threading-issue?
Just Google the exceptionm you need to marshal the form to the parent
through with Control.BeginIn voke (don't use Invoke as it can deadlock).

--
sp**********@ro gers.com (Do not e-mail)
Jan 2 '08 #2
Hi,

I came up with this solution:

#Region " Declarations "

Module Declarations

Friend fMdi As MainForm
Friend fChild As ChildForm

End Module

#End Region ' Declarations

#Region " ChildFroms "

Module ChildFroms

#Region " Delegates "

Delegate Sub AddChildDelegat e(ByVal child As Form)

#End Region ' Delegates

Friend Sub InstanciateForm ()
Dim Child As New ChildForm
Child.Text = "Do something"
Adding(Child)
End Sub

Public Sub Adding(ByVal Child As Form)
If fMdi.InvokeRequ ired Then
Dim AddChildDlg As New AddChildDelegat e(AddressOf Adding)
fMdi.BeginInvok e(AddChildDlg, Child)
Else
Child.MdiParent = fMdi
Child.Show()
End If
End Sub
End Module

#End Region ' ChildFroms

#Region " ChildForm "

Public Class ChildForm

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
MsgBox("Hello World")
End Sub

Private Sub ChildForm_Load( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
fChild = Me
End Sub

End Class

#End Region ' ChildForm

#Region " MainForm "

Imports System.Threadin g

Public Class MainForm

Private Sub MainForm_Load(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
fMdi = Me
Dim t1 As New Thread(New ThreadStart(Add ressOf
ChildFroms.Inst anciateForm))
t1.Start()
End Sub

End Class

#End Region ' MainForm
Regards,

Michael

"Spam Catcher" wrote:
=?Utf-8?B?TWljaGFlbCB NYWVz?= <mi**********@c ommunity.nospam wrote in
news:66******** *************** ***********@mic rosoft.com:
It is the assignment of the MdiParent which poses the problem.
'MDI' is a variable which references the instance of the Main (mdi)
Form (frmMain).
The generated exception is this: "Cross-thread operation not valid:
Control 'frmMain' accessed from a thread other than the thread it was
created on."

How can I solve this threading-issue?

Just Google the exceptionm you need to marshal the form to the parent
through with Control.BeginIn voke (don't use Invoke as it can deadlock).

--
sp**********@ro gers.com (Do not e-mail)
Jan 3 '08 #3

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

Similar topics

1
1451
by: Swaroop C H | last post by:
Is there a Python equivalent of Perl's IPC::Run module http://search.cpan.org/dist/IPC-Run/lib/IPC/Run.pm ] ? Thanks! -- Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info
0
2247
by: Kevin | last post by:
Configuration: Redhat AS 3.0 IBM DB2 8.1 fixpak 5 Problem: I am attempting to start a capture and get the following error message: 2004-06-10-10.46.34.625103 <Asnenv:setEnvIpcQRcvHdl> ASN8009D "Capture" : "ASN" : Could not get IPC queue with key(s) "(0x300542c4,
2
2816
by: J | last post by:
Hello, What is the best/easiest way to setup interprocess communication between a windows service and a webservice? The windows service will be running on the same machine that is hosting the web service. The web service will be calling the windows service to get information relating to the printers installed on this machine. J
1
1445
by: Andreas | last post by:
Hi, I'm developing a non-interactive C++ windows service (as support for interactive services will run out...) that shall communicate with a .net application on the local host. What's the best way this can be done? I've thought of window messages (by FindWindow, SendMessage, etc.) - but this requires the 'interactive' flag to be set.... Best wishes,
2
6666
by: a_agaga | last post by:
Do you know are there some reasons why many do not make processes to communicate through memory? Why network connections (sockets) are used so commonly in IPC (inter process communication) instead of memory? (Is IPC harder to maintain / handle if it is made through memory, when compared to communication through sockets?) Some background things:
2
2624
by: P | last post by:
Hello. I launch two programs in a machine. These programs communicate each other by TCP socket. (OS : Windows Server 2003 x64) Here is my question. Can I use UDP instead of TCP as IPC? Because they are in same machine, I think, there'd be no packet loss and even the orders of packet would be
0
1056
by: abdullah toprak | last post by:
Hi I would like to see an example, how can i write an windows service, which communicates with IPC Channel and a Form GUI. I have written some tests, but i receive an IPC-Port error: Access denied. I would like see an example, where i can see the functionality with IPC-Channel + Windows Servcice + GUI. Nice to have: implemented eventhandling, that the windows service update the GUI, when something changes in the services!
7
2675
by: Alex Y Wang | last post by:
Hi all, my current project is completely written in native C++, and for some reason I need to write a standalone .Net program to do some work for it. Therefore, I need to find an effective way of IPC between my unmanaged code and managed code. What's most appropriate IPC solution for this? Thanks in advance. Alex Y Wang
7
5479
by: adrin | last post by:
Hello, Could anybody tell me what are IPC mechanisms that .NET supports at present?(and what improvements were made in different framework versions)? Is IPC support windows dependent or is it designed to be more or less portable(does Mono support IPC?) tia --
0
994
gpraghuram
by: gpraghuram | last post by:
Hi, I have started writing some code using the IPC::Sharelite. I have written some pieces of code and i tried running the same . Following is the code #!/app/perl5.6/bin/perl use IPC::ShareLite; my $Shared_Memory_Key = 500; my $IP_FILE = "ip.txt";
0
8538
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,...
0
8961
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...
0
7627
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
6459
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
4324
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
4557
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2974
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
2238
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1957
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.