Follow me on Twitter at Twitter.com/wbm
FYI, I'm blogging most of my stuff over at More Wally now.
You might want to add my rss feed to your reader at:http://morewally.com/cs/blogs/wallym/rss.aspx
September 2004 - Posts - Wallace B. McClure

Wallace B. McClure

All About Wally McClure - The musings of Wallym on Web, HTML5, Mobile, Xamarin.iOS, Xamarin.Android, and Windows Azure.

News

Visual Studio Magazine Column Personal Blog

.NET

Book Authors

Business

Family

Friends

Georgia Tech Bloggers

Personal

Archives

September 2004 - Posts

MSMQ Processing of multiple pieces of data

You want to process a bunch of  data associated with a single MSMQ message.  First, create a class with the Serializable attribute.

[Serializable()]

public class cSearchUrl

{

      public string Url = String.Empty;

      public string ServerName = String.Empty;

      public long Id = 0;

}

Post the message

MessageQueue mq = new MessageQueue(gstrQueueForSearchResults);

cSearchResults objRes = new cSearchResults();

try

{

      objRes.UrlText = pText;

      objRes.Url = pstrUrl;

      objRes.Id = plngUrl;

      //Don't need this for the specific entry, but it is here.

      objRes.ServerName = cCommon.CalculateServerName(pstrUrl);

      mq.Send(objRes);

}

finally

{

      mq.Dispose();

      mq = null;

}

Then, I need to get the data on the other end.  Here is my setup code.

gMQSearchResults = new MessageQueue();

gMQSearchResults.Path = gstrQueueForSearchResults;

gMQSearchResults.Formatter = new XmlMessageFormatter(new Type[] {typeof(WebSearch.cSearchResults)});

gMQSearchResults.ReceiveCompleted += new ReceiveCompletedEventHandler(this.MQ_ReceiveCompleted_ForSearchResults );

gMQSearchResults.BeginReceive();

Here is my processing code.

private void MQ_ReceiveCompleted_ForSearchResults(object sender, ReceiveCompletedEventArgs e)

{

// Add code here to respond to message.

System.Messaging.Message msg = gMQSearchResults.EndReceive(e.AsyncResult);

WebSearch.cSearchResults cSearchRes;

try

{

      msg.Formatter = new XmlMessageFormatter(new Type[] {typeof(WebSearch.cSearchResults)}); //= new XmlMessageFormatter(new Type() {GetType(WebSearchSupport.cSearchResults)}); //new XmlMessageFormatter(new String(){"System.String, mscorlib"});

      cSearchRes = (WebSearch.cSearchResults)msg.Body;

      StoreUrlInSearchResults(cSearchRes);

}

      //Exception handling code

finally

{

      msg.Dispose();

      msg = null;

      if ( this.gblRunStatus == true )

      {

            gMQSearchResults.BeginReceive();

      }

}

 

}

I hope that this helps.  If you have any suggestions, let me know.

Wally

MSMQ processing of a string

Here is some sample code that processes messages that are in an MSMQ queue (isn't that redundant?).  It pulls a string from a defined queue and does something with it.  Behind the scenes, it uses the threadpool to process messages in the queue.

//do a bunch of setup stuff.

//this code could be within a winforms button click, form load, or the start of a Windows Service.

gMQSearchUrl = new MessageQueue();

gMQSearchUrl.Path = gstrQueueForSearchUrl;

gMQSearchUrl.Formatter = new XmlMessageFormatter(new string[]{"System.String, mscorlib"});

gMQSearchUrl.ReceiveCompleted += new ReceiveCompletedEventHandler(this.MQ_ReceiveCompleted_ForSearchUrl );

gMQSearchUrl.BeginReceive();

 

private void MQ_ReceiveCompleted_ForSearchUrl(object sender, ReceiveCompletedEventArgs e)

{

      // Add code here to respond to message.

      //new XmlMessageFormatter(new String(){"System.String, mscorlib"});

      System.Messaging.Message msg = gMQSearchUrl.EndReceive(e.AsyncResult);

      msg.Formatter = new XmlMessageFormatter(new String[]{"System.String, mscorlib"});

      string strBody = (string)msg.Body;

      try

      {

     //Do something with the message that is stored in strBody.

      }

     //Exception handling code

      finally

      {

            if ( this.gblRunStatus == true )

            {

                  //You have to recieve the next message.

                  gMQSearchUrl.BeginReceive();

            }

            msg.Dispose();

            msg = null;

      }

 

}

 

Non-Technical Observation about Technology: Cell phone users are the new smokers

Ever notice how smokers congregate around a doorway on the outside of a building?  Well, I see that cell phone users are now doing the same.

Wally

Non-Technical - Adware/Spyware developers and marketing folks are not my favorite people

At one of my customer's, when I am not there, someone else will use the computer that I use, due to resource limitations.  That is fine with me, I'm not there all the time.  Unforntunately, about a month ago, one of these folks somehow got hoodwinked into installing some adware/spyware.  Now, whenever, I show up in the morning, I get one popup screen after another (AOL 9.0, MSN, Refurbished Dell computers (like I would ever buy a Dell again), and such) on this development computer.  I have tried Spybot and Ad-Aware SE.  Spybot sees almost nothing (yes it is fully updated).  Ad-Aware SE sees some of these files, but whenever I instruct Ad-Aware to remove the files, these same files keep coming back.  I'm not criticizing Spybot and Ad-Aware for being bad products, merely that they can't handle the current situation.  I have googled for all of these adware, spyware, malware products, but I have never been able to get these scum bags removed.  These products are wupdt.exe, polmx3.exe, and qwnpln.exe.  I am fearful that the only way to resolve this problem is going to be to repave and start over with this machine. About 12 months ago, someone installed some adware product at my office.  It messed up everything with the computer and the only solution was to repave.  About 3 months ago, I got caught by the Download.Ject virus and I just repaved and started over.  These spyware people wonder why no one likes them.......Geez.

Now, I am hearing that there are moves afoot to outlaw, at the state and federal level, spyware-adware type of programs.  Good.  The problem is that these same folks that run these adware-spyware companies are crying about how what they are doing is just fine and that the only way that their software is installed is if the user allows this to happen.  Well, I didn't allow this to happen on this machine, yet, I am now stuck with the consequences of someone else's actions.  BTW, have you tried to run the uninstall for these programs?  Oh, I forgot, the uninstall does not exist.  Another argument for these adware/spyware marketeers is that what they are doing is protected by the United State's First Amendment Right to Freedom of Speech.  Well, that sounds all well and good, but I did not give them the right to market their products to me when I am trying to work.  Yesterday afternoon, every minute, I was interrupted with some new popup ad.  I seriously doubt that is protected by the "Freedom of Speech" Amendment.  Wonder how those adware/spyware types would like it if I called their office every minute for a few days in a row.  Oh yeah, I think that there is something I learned about in school where the "Freedom of Speech" does not extend to yelling fire in a crowded room and that the freedom to do as you please stops when it effects others.

If the people that develop and market these adware/spyware products want to keep their products from being made illegal, they need to:

  • Quit attempting to confuse people with the "X" within another "X" to attempt  to get people to download their products.  Quit telling people that their computer's aren't optimized.
  • Create a standard windows uninstall.  I am sick of your tricks.  Gee, I don't see a standard windows uninstall on this system for any of these products.. 

Until these two (and other) things are done, if you make or market some type of adware/spyware, you will not be on my Christmas card list.

Wally

Optimizing Indexes with Sql Server 2005 (Yukon) Beta 2

If you want to optimize your indexes in Sql Server 2000, you probably used the DBCC REINDEX or DBCC INDEXDEFRAG commands.  I like the DBCC INDEXDEFRAG because I don't have to take the table offline from the application.  I've been looking at for a similar mechanism in Sql Server 2005 (Yukon).  I have found the ALTER INDEX command.  The advantage that it has over the DBCC INDEXDEFRAG command is that with a DBCC INDEXDEFRAG command, you must manually specify the indexes that you want to defrag.  Why am I looking for this?  According to the documentation, DBCC INDEXDEFRAG will be removed from a future version of Sql Server.

Wally

Registration free COM?

http://www.ftponline.com/vsm/2004_en/magazine/online/saad/

I just read about this online today.  I think it will ship in VS.NET 2k5.

Wally

Have you seen this in Yukon Beta 2? NewSequentialId() joins the fray

There is a new command in Yukon Beta 2 for generating GUIDs / uniqueidentifiers.  It is the NewSequentialId() method.  I don't know if it will eliminate the potential performance problems I have seen when using uniqueidentifiers, but it is there.  I don't know if it will make it to the final released version.

SELECT NEWSEQUENTIALID()
UNION ALL
SELECT NEWSEQUENTIALID()
UNION ALL
SELECT NEWSEQUENTIALID()

results in this output:

4d6e4dbb-8706-d911-afcb-000f1f1b2c2a
4e6e4dbb-8706-d911-afcb-000f1f1b2c2a
4f6e4dbb-8706-d911-afcb-000f1f1b2c2a

I can't even take credit for this.  Jimmy Nilsson mentioned it on his blog yesterday and I just ran across it.

http://www.jnsk.se/weblog/posts/combkiller.htm

Posted: Sep 14 2004, 03:54 PM by Wallym | with no comments
Filed under:
Trying to Debug with Win64 and Whidbey .NET Beta 1?

If you are trying to debug using Win64 and Whidbey .NET Beta 1, and you get an error about the remote debugging components not being installed, check out this tip I got from Jeff Schwartz in one of the newsgroups.

On the VS install CD there should be a package under "remotedbg\<processor
architecture>\" called rdbgsetup.exe.  Installing this package on the
target machine will install msvsmon.exe.

Hooray, my Dell Laptop works again

After two new keyboards, my Inspiron 8200's pointing stick works again.  Yippeee. Finally. It only took two new keyboards plus the replacement that they did for me at the depot to fix the problem.  I amnot happy with the way Dell handled the situation.  One would think that they would send it back from the depot working properly the first time.  Second, they sent two faulty keyboards to me.  It was the third keyboard that resolved the problem...........Ok, enough whining about that. I am back and I am working.

http://weblogs.asp.net/wallym/archive/2004/08/13/214350.aspx

Wally

The US Economy is definitely on the upswing

The US Economy is definitely on the upswing.  Want to know why I know that?  Because in the last couple of months, the body shop headhunters have been coming out of the woodwork wanting me to come work for them.  I have now been contact 3 times in the last week and 5 times in the last month.  All I have to do is take a pay cut and sign away every bit of intellectual property I own and I can belong to them.  Oh, oh, what should I do........

Wally

Posted: Sep 13 2004, 09:20 PM by Wallym | with no comments
Filed under:
More Posts « Previous page - Next page »