473,379 Members | 1,260 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

How to do this C# code in VB??

This is some C# code out of a book that is part of a server component using
Application state. I'm trying to convert it to VB. I can't find the VB
equivilent of the Lock. I thought it might be a Mutex but those docs look
different. What is the VB equivelent of the Lock code below?
Thanks,
G

protected override void OnLoad(EventArgs e) {
base.OnLoad(e);
switch (TrackingMode){
case PageTrackingMode.ByApplication:
// Update the page hits in the Application
// object. This operation needs a lock because
// multiple users could access a page at the same
// time.
lock(Page.GetType()){
Page.Application[HitsKey] = Hits + 1;
}
break;
Nov 21 '05 #1
8 1219
"G Dean Blake" <gb@nospam.com> wrote in
news:#y**************@TK2MSFTNGP12.phx.gbl:
This is some C# code out of a book that is part of a server component
using Application state. I'm trying to convert it to VB. I can't
find the VB equivilent of the Lock. I thought it might be a Mutex but
those docs look different. What is the VB equivelent of the Lock code
below? Thanks,
G

protected override void OnLoad(EventArgs e) {
base.OnLoad(e);
switch (TrackingMode){
case PageTrackingMode.ByApplication:
// Update the page hits in the Application
// object. This operation needs a lock because
// multiple users could access a page at the same
// time.
lock(Page.GetType()){
Page.Application[HitsKey] = Hits + 1;
}
break;


Could that be a HttpApplicationState.Lock (Application.Lock)?

http://msdn.microsoft.com/library/de...l=/library/en-
us/cpref/html/frlrfSystemWebHttpApplicationStateClassLockTopic.a sp

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 21 '05 #2
The VB.NET equivalent is SyncLock:

SyncLock Page.GetType()
Page.Application(HitsKey) = Hits + 1
End SyncLock

hope that helps..
Imran.

"G Dean Blake" <gb@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
This is some C# code out of a book that is part of a server component using Application state. I'm trying to convert it to VB. I can't find the VB
equivilent of the Lock. I thought it might be a Mutex but those docs look
different. What is the VB equivelent of the Lock code below?
Thanks,
G

protected override void OnLoad(EventArgs e) {
base.OnLoad(e);
switch (TrackingMode){
case PageTrackingMode.ByApplication:
// Update the page hits in the Application
// object. This operation needs a lock because
// multiple users could access a page at the same
// time.
lock(Page.GetType()){
Page.Application[HitsKey] = Hits + 1;
}
break;

Nov 21 '05 #3
"Imran Koradia" <no****@microsoft.com> schrieb:
The VB.NET equivalent is SyncLock:

SyncLock Page.GetType()
Page.Application(HitsKey) = Hits + 1
End SyncLock


If possible, avoid locking on a type object...

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #4
Here's an article that explains why:

http://msdn.microsoft.com/library/de...ui06032003.asp
--
Scott Swigart
http://blog.swigartconsulting.com

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:en**************@TK2MSFTNGP11.phx.gbl...
"Imran Koradia" <no****@microsoft.com> schrieb:
The VB.NET equivalent is SyncLock:

SyncLock Page.GetType()
Page.Application(HitsKey) = Hits + 1
End SyncLock


If possible, avoid locking on a type object...

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #5
I'm in a class inherrited from WebControl and there is no Application object
as there is when in an aspx page.
G
"Lucas Tam" <RE********@rogers.com> wrote in message
news:Xn**************************@140.99.99.130...
"G Dean Blake" <gb@nospam.com> wrote in
news:#y**************@TK2MSFTNGP12.phx.gbl:
This is some C# code out of a book that is part of a server component
using Application state. I'm trying to convert it to VB. I can't
find the VB equivilent of the Lock. I thought it might be a Mutex but
those docs look different. What is the VB equivelent of the Lock code
below? Thanks,
G

protected override void OnLoad(EventArgs e) {
base.OnLoad(e);
switch (TrackingMode){
case PageTrackingMode.ByApplication:
// Update the page hits in the Application
// object. This operation needs a lock because
// multiple users could access a page at the same
// time.
lock(Page.GetType()){
Page.Application[HitsKey] = Hits + 1;
}
break;


Could that be a HttpApplicationState.Lock (Application.Lock)?

http://msdn.microsoft.com/library/de...l=/library/en-
us/cpref/html/frlrfSystemWebHttpApplicationStateClassLockTopic.a sp

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/

Nov 21 '05 #6
True..just gave the OP the VB.NET equivalent...

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:en**************@TK2MSFTNGP11.phx.gbl...
"Imran Koradia" <no****@microsoft.com> schrieb:
The VB.NET equivalent is SyncLock:

SyncLock Page.GetType()
Page.Application(HitsKey) = Hits + 1
End SyncLock


If possible, avoid locking on a type object...

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #7
"Imran Koradia" <no****@microsoft.com> schrieb:
True..just gave the OP the VB.NET equivalent...


I know :-).

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #8
ah, that's it.
thanks,
G

"Imran Koradia" <no****@microsoft.com> wrote in message
news:Ob**************@TK2MSFTNGP11.phx.gbl...
The VB.NET equivalent is SyncLock:

SyncLock Page.GetType()
Page.Application(HitsKey) = Hits + 1
End SyncLock

hope that helps..
Imran.

"G Dean Blake" <gb@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
This is some C# code out of a book that is part of a server component

using
Application state. I'm trying to convert it to VB. I can't find the VB
equivilent of the Lock. I thought it might be a Mutex but those docs
look
different. What is the VB equivelent of the Lock code below?
Thanks,
G

protected override void OnLoad(EventArgs e) {
base.OnLoad(e);
switch (TrackingMode){
case PageTrackingMode.ByApplication:
// Update the page hits in the Application
// object. This operation needs a lock because
// multiple users could access a page at the same
// time.
lock(Page.GetType()){
Page.Application[HitsKey] = Hits + 1;
}
break;


Nov 21 '05 #9

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

Similar topics

51
by: Mudge | last post by:
Please, someone, tell me why OO in PHP is better than procedural.
9
by: bigoxygen | last post by:
Hi. I'm using a 3 tier FrontController Design for my web application right now. The problem is that I'm finding to have to duplicate a lot of code for similar functions; for example, listing...
4
by: jason | last post by:
Hello. Newbie on SQL and suffering through this. I have two tables created as such: drop table table1; go drop table table2; go
16
by: Dario de Judicibus | last post by:
I'm getting crazy. Look at this code: #include <string.h> #include <stdio.h> #include <iostream.h> using namespace std ; char ini_code = {0xFF, 0xFE} ; char line_sep = {0x20, 0x28} ;
109
by: Andrew Thompson | last post by:
It seems most people get there JS off web sites, which is entirely logical. But it is also a great pity since most of that code is of such poor quality. I was looking through the JS FAQ for any...
5
by: ED | last post by:
I currently have vba code that ranks employees based on their average job time ordered by their region, zone, and job code. I currently have vba code that will cycle through a query and ranks each...
0
by: Namratha Shah \(Nasha\) | last post by:
Hey Guys, Today we are going to look at Code Access Security. Code access security is a feature of .NET that manages code depending on its trust level. If the CLS trusts the code enough to...
18
by: Joe Fallon | last post by:
I have some complex logic which is fairly simply to build up into a string. I needed a way to Eval this string and return a Boolean result. This code works fine to achieve that goal. My...
37
by: Alan Silver | last post by:
Hello, Newbie here, so please forgive what is probably a basic question ... I see a lot of discussion about "code behind", which if I have understood correctly, means that the script code goes...
171
by: tshad | last post by:
I am just trying to decide whether to split my code and uses code behind. I did it with one of my pages and found it was quite a bit of trouble. I know that most people (and books and articles)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.