Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Compact Framework / April 2006

Tip: Looking for answers? Try searching our database.

Multiform multi-process

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
hakan aktan - 28 Apr 2006 16:16 GMT
Hi all,
I have 2 wince forms and fisrst form causes second to launh.While some
process is running on first
I need second form to have a hard process too. I tried thread, timer and
while , they did not work.
The forms are being locked after a few seconds.Is there another way ,i need
anything that works multi processes on multiform.
Here is my code: (Wince 4.2 OS , Coding VB.Net 2003 on CF 1.1)

Thanx in advance
Form1:
'--------------
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim frm2 As New Form2

frm2.Show()

'This job has to work until main Form1 is closed

While (True)

Application.DoEvents()

System.Threading.Thread.Sleep(1000)

'Do stg

End While

'Form2 Code

  Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
       Dim th As Thread
       th = New Thread(AddressOf mySub)
       th.Start()
   End Sub
   Private Sub mySub()
       While(MoveForward)
           Application.DoEvents()
           System.Threading.Thread.Sleep(300)
           'Do stg
       Next
   End Sub

Signature

Hakan Aktan
Software Developer

<ctacke/> - 28 Apr 2006 17:35 GMT
You need to use threads.

-Chris

> Hi all,
> I have 2 wince forms and fisrst form causes second to launh.While some
[quoted text clipped - 42 lines]
>        Next
>    End Sub
hakan aktan - 29 Apr 2006 08:46 GMT
Thanx for your reply Mr Tacke. But i have a little problem about threads.
In my main form ( code below my first mail) , i have a few function that
communicates from
comm1 port sequencely and saves data (comes from ports) to hash tables.
My second form shows these datas from hashtable by graphics by refreshing
every 2 seconds.
Main form must communicate with port until it is closed.
But when i use thread at form1 comm port datas mix and later gives
error.(CFSerial.Dll)
Because my communicate functions tries to work together on 1 port at the
same time when i use thread.
When they lose sequence , comm port locks..
Thanx in advance for any idea about this scenario...
Signature

Hakan Aktan
Software Developer

"<ctacke/>" <ctacke[@]opennetcf[dot]com>, haber iletisinde þunlarý
yazdý:OztWGHuaGHA.4784@TK2MSFTNGP02.phx.gbl...

> You need to use threads.
>
[quoted text clipped - 46 lines]
>>        Next
>>    End Sub
DJMatty - 29 Apr 2006 09:55 GMT
Hi

I think Chris is right, you need to run a single thread that
communicates with the com port and stores the data in a thread safe
manner.

The main application thread can read the data that is stored by the
worker thread from the serial port and display it.

You can't update form controls from a worker thread as this needs to be
done from the main thread. You can use the BeginInvoke method in your
worker thread to signal to your main thread that controls need
updating.

Have a look at this article.

http://www.yoda.arachsys.com/csharp/threads/winforms.shtml

This is quite interesting too:

http://www.codeproject.com/csharp/begininvoke.asp

It seems that .Net 2.0 checks for cross thread ui updates and throws
exceptions.

Matt
<ctacke/> - 29 Apr 2006 12:25 GMT
No, the main form should *not* be talking with the serial port.  That's the
root of your problem.  Move your comms to a separate thread, or use
event-based programming instead of polling (which is how the serial classes
are designed anyway).

-Chris

> Thanx for your reply Mr Tacke. But i have a little problem about threads.
> In my main form ( code below my first mail) , i have a few function that
[quoted text clipped - 59 lines]
>>>        Next
>>>    End Sub

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.