Sunday, August 9, 2009

SQLSaturday - Miami

What an awesome event! Well over 200 attendees, 5 tracks, and fantastic speakers. Thanks for all of youu who helped make this event so successful. And it was just the first of its kind in South Florida. For sure we will see it come back.

I presented a session on the new data types and support for non-relational data in SQL Server 2008. Basically a repeat of the session I co-presented with Michael Rys at TechEd. We discussed filestream, hierarquy id, sparse columns, spatial data, and XML lax validation.

I will post my slides and demos soon.

Tuesday, June 9, 2009

Learn to build distributed multiplayer games with cloud messaging

I am sitting a presentation by Jason Milgram, co-founder of Linxter (www.linxter.com), on their cloud messaging service. Jason and his buddies at Linxter developed a messaging middleware service over the internet. The service is easy to use compared to other middleware messaging systems like IBM Q-Series or Microsoft Message Queue services. Developers do not have to go through the hassle of installing and configuring these systems, they simply call Linxter's services passing in messages and requesting new messages. Hassle free message anagement at it's best!

They offer a free 30-day evaluation period, and their basic fee is only $5/month for up to 1,000,000 messages! Now I need a cloud storage solution to go with that!

Jason's presentation was done at DeVry University in Miramar, FL as part of the Florida .NET User groups (www.fladotnet.com). The group meets every second Tuesday of the month at the Univesity. There are 3 other fladotnet groups, each meeting at a given Tuesday. Next week, 6/16, we meet at the Microsoft office in Fort Lauderdale to discuss non-relational data in SQL Server 2008. Don;t miss our events!

Wednesday, March 4, 2009

Developing Location Based Applications with Microsoft Virtual Earth

Yesterday, 3/3/2009, I visited the Citrix building on West Cypress Creek Rd in Fort Lauderdale to give a presentation on Virtual Earth development for members of the Florida .NET user group (fladotnet.com). There were over a dozen developers, eager to hear and discuss the capabilities of VE. The presentation began on time at 6:30 PM and went on until 9:00 PM. Some of the attendees stayed a bit further to talk about Deep Zoom and Map Cruncher. From my perspective, it looked like we were all having a lot of fun. I want to thank Bill Schulz for being our host, the entire team at fladotnet for welcoming me on board, and the developers that attended the session for their participation.

If you want the presentation and code we developed, you can find it here.

Wednesday, February 25, 2009

FlaDotNet

It's been two years since I last participated in any kind of user group meeting. I felt a bit ashamed since I was always involved in the different communities in Brazil, Tampa, and Indiana. The answer to my desire of giving back to the community came by email. More specifically, an email from Dave Noderer(MVP). Dave manages the Florida .NET user groups in Miramar, Fort Lauderdale and West Palm. He was asking for volunteers to help line up speakers. The email could not have come in a better time. I contacted Dave and after some emails exchange I joined the excellent team at FlaDotNet.

I attended my first meeting last night in West Palm, a 90 minute drive from work. There I met Morgan Baker, the West Palm group leader, and Vishal Shukla, the speaker for the event.

Vishal showed a great enthusiasm while talking about Azure and SDS (SQL Data Services) that I could not wait to get home and download the Public CTP. Needless to say I played with the new toy until it was time to work this morning.

I am very excited with the Florida .NET groups. So much so that I will be presenting a session on Virtual Earth development on March 3rd in Fort Lauderdale at 6:30 PM. During the session I will share some of the challenges and solutions I found along the course of building location based applications for Blue Dasher Technologies. I will also demonstrate some solutions my team has built and show how we did it. I will also make my toolbox of VE related items available to the general public. To register for the event go here.

Friday, January 30, 2009

Using Unmanaged Arrays in C#

Yesterday I faced an interesting problem I had not dealt with in a real world scenario before. We hired the services of a C++ developer to create a native C++ class for us that would allow our applications to control some of the cameras we use for street level imagery collection and processing. And when I received the first version of the DLL for testing I realized that my team was a pure C# team with little to no exposure to C++.

After testing the DLL in native C++ and asserting it had the desired performance and reliability I was ready to wrap it using a managed C++ class. I had done that several times and was confident I would be done in minutes. I openned the UnmanagedClass.h file to see the method signatures and thought it was going to be a piece of cake. The code segment below represents part of the UnmanagedClass.h file.

UnmanagedClass(void);
virtual ~UnmanagedClass(void);
unsigned int GetNumberOfImages();
bool InitializeConvert(string a);
bool CreateJPGs(int selectedImagesToProcess[]);


With that information in hands I created my ManagedClass.cpp file with the following code:

public ref class ManagedClass{
public:
ManagedClass(){o = new UnmanagedClass();}
virtual ~ManagedClass(){o->~UnmanagedClass();}
bool InitializeConvert(System::String ^ a){
return o->InitializeConvert(a);}

bool CreateJPGs(int selectedImagesToProcess[]){
return o->CreateJPGs(selectedImagesToProcess);}


private:
UnmanagedClass * o;
};



The initial problem I faced was the fact that the managed class used System::String and the native class used std::string. I did not want to have our C# developers use std::string and decided to let them pass in a managed string data type and handle the conversion in that wrapper class (ManagedClass). I did some digging and found some old code from my teaching days to do that. I remember that was copied straight from MSDN. Here's the InitializeConvert method after changes:


bool InitializeConvert(System::String ^ a){
string s;
using namespace Runtime::InteropServices;
const char* x = (const char*)(Marshal::StringToHGlobalAnsi(a)).ToPointer();
s = x;
Marshal::FreeHGlobal(IntPtr((void*)s));
return o->InitializeConvert(a);

}

Finally, I was ready to tackle the CreateJPEGs method. The issue here is that the method expects an unmanaged array. I tried to solve the issue inside the wrapper class but after some reasearch I found an awesome article on codeproject that explained how, and more importantly, why, I needed to use unamanged arrays. You can see the article here.

Following the article I created the exact same class they refer as example, copied below.


public ref class Unmanaged abstract sealed
{
public:
generic where T : value class
static void* New(int elementCount)
{
return Marshal::AllocHGlobal(sizeof(T) * elementCount).ToPointer();
}
generic where T : value class
static void* NewAndInit(int elementCount)
{
int sizeInBytes = sizeof(T) * elementCount;
void* newArrayPtr = Marshal::AllocHGlobal(sizeInBytes).ToPointer();
memset(newArrayPtr, 0 , sizeInBytes);
return newArrayPtr;
}
static void Free(void* unmanagedPointer)
{
Marshal::FreeHGlobal(IntPtr(unmanagedPointer));
}
generic where T : value class
static void* Resize(void* oldPointer, int newElementCount)
{
return Marshal::ReAllocHGlobal(IntPtr(oldPointer),
IntPtr((int) sizeof(T) * newElementCount)).ToPointer();
}
};


With that there were no changes required for my wrapper. All I needed now was to teach the C# developers how to use the Unmanaged class to create an unmanaged array and pass that as a parameter to the wrapper. With that said, here's a piece of C# code using the wrapper class:

ManagedClass pgr = new ManagedClass();
unsafe{
int selectedItems = lstImages.SelectedItems.Count; //lstImages is a listbox
int* imagesToProcess = (int*)Unmanaged.NewAndInit(selectedItems);
int i = 0;
foreach (int index in lstImages.SelectedIndices)
imagesToProcess[i++] = index;
pgr.CreateJPGs(imagesToProcess);
Unmanaged.Free(imagesToProcess);

}

Finally I had some code I could use from C# to use the native C++ class created by our vendor.