473,545 Members | 2,005 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Treading for console applications in VB.NET

I have used threading in Windows applications successfully. I am trying
to write a console application using synchronized threads, as I don't
need any display or operator interface.

However, when I call Monitor.Wait on any thread created, an exception is
thrown with the following description:

"Object synchronization method was called from an unsynchronized block
of code."

I've searched for any statement on this, but there is nothing definitive
that says threading in a console application is not allowed. Some of
the code samples imply a console app.

Is threading (or at least synchronizing threads) simply not possible in
a console application?
Frank Maxey

*** Sent via Developersdex http://www.developersdex.com ***
Jun 12 '06 #1
2 1663
Frank,

Monitor.Wait can only be called with the thread currently owns the
lock. That means a previous call to Monitor.Enter (or by using the
SyncLock keyword) has occurred.

Brian

fdmaxey wrote:
I have used threading in Windows applications successfully. I am trying
to write a console application using synchronized threads, as I don't
need any display or operator interface.

However, when I call Monitor.Wait on any thread created, an exception is
thrown with the following description:

"Object synchronization method was called from an unsynchronized block
of code."

I've searched for any statement on this, but there is nothing definitive
that says threading in a console application is not allowed. Some of
the code samples imply a console app.

Is threading (or at least synchronizing threads) simply not possible in
a console application?
Frank Maxey

*** Sent via Developersdex http://www.developersdex.com ***


Jun 12 '06 #2

That worked. Thank you.

Frank Maxey

*** Sent via Developersdex http://www.developersdex.com ***
Jun 12 '06 #3

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

Similar topics

0
2021
by: Bryan Olson | last post by:
New and improved! Love Python's stack-tracing error messages, but hate the way GUI applications throw the messages away and crash silently? Here's a module to show Python error messages that would otherwise be lost in console-less programs. Graphical applications should not require console windows, but they do need a workable...
3
2287
by: Dave | last post by:
I created a console app in Visual Studio 2003 using C#. How to I distribute this app after I build it? It is my understanding that a C# app will run on any machine with the Net Framework installed. Do I simply copy the exe file to the machine on which the console app is to run?
5
11200
by: Barry Mossman | last post by:
Hi, can I detect whether my class is running within the context of a Console application, vs say a WinForm's application ? also does anyone know whether the compiler or runtime is smart enough to avoid the overhead of writing to the console if it is not visible, eg I am running inside a WinForm application. thanks
4
1307
by: Rob | last post by:
When issuing... System.Console.Write and WriteLine commands... the program shells out to Command prompt, displays message, and closes... there is no time to view what is shown,,, how can you keep the console up in order to view the contents ? Thanks
1
287
by: Allen Maki | last post by:
I would appreciate if someone helps me. I am reading a book called MS visual c++ .net step by step. I am using Visual C++ .net version 2003. I am trying to learn reading from file using system::io. I have been asked to build the application, open a console window, change to the project's Debug directory, and run the program with a...
4
10492
by: Peter Nimmo | last post by:
Hi, I am writting a windows application that I want to be able to act as if it where a Console application in certain circumstances, such as error logging. Whilst I have nearly got it, it doesn't seem to write to the screen in the way I would expect. The output is:
24
2437
by: arnuld | last post by:
i want to create a console application in C++ . what can be the 1st step ? NOTE: i did use Google but that gives me some VC++ based links using non-standard libraries.
3
10100
by: Alex | last post by:
Hello, I'm wroting a console utility in VB 2005, and I need the ability to pass parameters to the application when the program runs. For example, if my program is called testing.exe, I need to be able to run this: c:\testing.exe c:\test ....and have 'c:\test' passed to the program as a variable. Most of my VB books focus on web forms...
3
2233
by: Sheikko | last post by:
Sincerly is a little bit complicated to explain to you what I have in my mind, but I will try: Above all the problem is the type of data that I want to passe between these two applications. The complete application that I want to create consiste of two applications: - the console developped with VS C++, that use some libraries developped...
0
7479
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7926
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...
1
7439
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...
0
7773
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...
1
5343
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...
0
3468
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...
0
3450
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1028
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
722
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...

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.