Click here to Skip to main content
11,490,642 members (71,046 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# VB.NET
Hi,


with the help of remoting I created client and server two applciation. From client application I am handling server
side events. but problem is that after I invoke event.Event
back tracking is going on. server application is opening from
sub main. After I call event from client applicaiton evnet back
tracking is going on and event start going back and back up to
sub main. and ging error of form.show.

Could you please suuges how should I stop event back tracking

Thanks
Posted 6-Feb-13 6:51am
Comments
Sergey Alexandrovich Kryukov at 6-Feb-13 12:40pm
   
What is "event backtracking"? "Backtracking" is some algorithm, not related to events. Do you mean something I don't know? Please describe what do you mean by event backtracking, exactly.
—SA
Quazi Areeb at 7-Feb-13 2:19am
   
No I am not talking about Backtracking algorithm.i.e. my form is opening from sub main function using from.show. I have one event Hello() which is I am calling from another application. after all code execute cursor goes to back to form.show. but I want after complete Hello event, code execution should stop. I tried with return; but not worked

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Events are not one way, if you are debugging and tracing your events, the event calls a function (the receiver) and when it is finished the call stack MUST collapse back up to the event firing routine.

What I think your problem is, is that you are interacting on the UI from a different thread (events are spawned in new threads). Interacting with a form from an event will cause an exception (where the event is fired, not where you interact with the UI).

In order to interact with the UI, you have to invoke (using the Form.Invoke or Control.Invoke) methods if the InvokeRequired flag is true on the form or control. This is true even when opening new forms or setting properties of existing controls or forms, otherwise you can get an IllegalCrossThreadException or an application hang.
  Permalink  
Comments
Quazi Areeb at 7-Feb-13 2:14am
   
Yes you are right but I already used InvokeRequired flag is true with form.Invoke and things working fine. but in some scenario they are not. for ex. I Invoke method from another application after method execution completed cursor automatically goes to form.show which is in sub main and giving error. I want after my method code execute code execution should stop there and not to go to form.show
Sergey Alexandrovich Kryukov at 8-Feb-13 1:30am
   
InvokeRequired only indicates the call from a thread other then UI thread, nothing else. Invoke is a mechanism of invocation of delegates on the UI thread.
Everything you are talking about simply makes no sense, as it is based on some misconception.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 476
1 Andy Lanng 288
2 Sascha Lefèvre 240
3 OriginalGriff 178
4 Maciej Los 160
0 Sergey Alexandrovich Kryukov 9,713
1 OriginalGriff 8,475
2 Sascha Lefèvre 3,544
3 Maciej Los 3,106
4 Richard Deeming 2,370


Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 6 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100