Home » Support » Client Content
CoSort Client Content 

It is possible to call functions in unmanaged code such as the SortCL API from within a C# application. This allows the software developer to leverage the speed, power, and efficiency of the CoSort data manipulation engine.

This model invokes the sortcl_routine() library function from within a C# class:

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Copyright 2008 Innovative Routines International (IRI), Inc.
* All Rights Reserved.
* donp @iri.com * 2008-03-20
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace csExample {
unsafe public partial class mainForm : Form {
[DllImport(”libsortcl.dll”)]
static extern void* sortcl_alloc();
[DllImport(”libsortcl.dll”)]
static extern int sortcl_routine(
void* pSortcl,
string sCommand);
[DllImport(”libsortcl.dll”)]
static extern void sortcl_free(void* pSortcl);
string sCommand;
int iReturn = -1;
void* pSortcl = null;

public mainForm() {

InitializeComponent();
}
private void buttonExit_Click(object sender, EventArgs e) {
Application.Exit();
}
private void buttonRun_Click(object sender, EventArgs e) {
sCommand = textBoxCommand.Text;
try {
if (null != (pSortcl = sortcl_alloc())) {
iReturn = sortcl_routine(pSortcl, sCommand);
sortcl_free(pSortcl);
}
labelReturn.Text = String.Format(”previous run returned: {0}”, iReturn);
}
catch {
labelReturn.Text = String.Format(”previous run threw an exception”);
}
}
}
}

The above model demonstrates invoking the sortcl_routine() library function from within a C# class. An example project using this class is available with CoSort v 9.1.2.