Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Branch: master

Merge pull request #35 from iron-io/v1-add-schedule-id

Add schedule_id to TaskInfo of v1
latest commit 20be3fe503
@rkononov rkononov authored


IronSharp is a .NET client for

Forked from grcodemonkey/iron_sharp

Getting Started

  1. Sign up at
  2. Get your credentials from
  3. Check out the wiki


PM> Install-Package Iron.IronMQ

// =========================================================
// MQ
// =========================================================

IronMqRestClient ironMq = IronSharp.IronMQ.Client.New();

// Get a Queue object
QueueClient queue = ironMq.Queue("my_queue");

QueueInfo info = queue.Info();


// Put a message on the queue
string messageId = @queue.Post("hello world!");


// Get a message
QueueMessage msg = queue.Get(n:30, timeout: 60, wait: 100);


//# Delete the message
bool deleted = msg.Delete();

Console.WriteLine("Deleted = {0}", deleted);

// Post several messages
queue.Post(new[] { "Hello", "world" });

MessageCollection messages = queue.Get(n: 2, timeout: 60, wait: 30);
// You can specify only parameters you need:
// MessageCollection messages = queue.Get(wait: 15);

// Post several messages
var payload1 = new
    message = "hello, my name is 1"

var payload2 = new
    message = "hello, my name is 2"

var payload3 = new
    message = "hello, my name is 3"

MessageIdCollection queuedUp = queue.Post(new[] {payload1, payload2, payload3});


QueueMessage next;

while (queue.Read(out next))


PM> Install-Package Iron.IronWorker


// =========================================================
// Worker
// =========================================================

IronWorkerRestClient workerClient = IronSharp.IronWorker.Client.New();

string taskId = workerClient.Tasks.Create("Test", new {Key = "Value"});

Console.WriteLine("TaskID: {0}", taskId);

TaskInfoCollection taskInfoCollection = workerClient.Tasks.List("Test");

foreach (TaskInfo task in taskInfoCollection.Tasks)

ScheduleOptions options = ScheduleBuilder.Build().

var payload = new
    a = "b",
    c = new[] {1, 2, 3}

ScheduleIdCollection schedule = workerClient.Schedules.Create("Test", payload, options);



Queuing a Task

string taskId = workerClient.Tasks.Create("Test", payload, options);

Where payload could be any object:

var payload = new {environment = "development", names = new String[]{"Bob", "Alice"}};

There are following possible Options:

  • Priority: Setting the priority of your job. Valid values are TaskPriority.Default (0), TaskPriority.Medium (1), and TaskPriority.High (2). The default is 0.
  • Timeout: The maximum runtime of your task in seconds. No task can exceed 3600 seconds (60 minutes). The default is 3600 but can be set to a shorter duration.
  • Delay: The number of seconds to delay before actually queuing the task. Default is 0.
  • label: Optional text label for your task.
  • cluster: cluster name ex: "high-mem" or "dedicated". This is a premium feature for customers to have access to more powerful or custom built worker solutions. Dedicated worker clusters exist for users who want to reserve a set number of workers just for their queued tasks. If not set default is set to "default" which is the public IronWorker cluster.

Scheduling Options

You can append to ScheduleBuilder.Build() (i.e. instance of ScheduleOptionsBuilder) the following methods:

  • WithFrequency: The amount of time specified with timespan, between runs. By default, the task will only run once. It will return a 400 error if it is set to less than 60. Original API parameter name is run_every.
  • StopAt: The time tasks will stop being queued. Should be an instance of DateTime. Original API parameter name is end_at.
  • StopAfterNumberOfRuns: The number of times a task will run. Original API parameter name is run_times
  • WithPriority: The priority queue to run the job in. Valid values are TaskPriority.Default (0), TaskPriority.Medium (1), and TaskPriority.High (2). The default is 0. Higher values means tasks spend less time in the queue once they come off the schedule. Original API parameter name is priority
  • StartingOn: The time the scheduled task should first be run. Should be an instance of DateTime. Original API parameter name is start_at.
  • RunFor: The amount of time specified with timespan scheduled task should be run for. The same as StopAt(DateTime.Now + duration)
  • Delay: The amount of time execution should be delayed. The same as StartingOn(DateTime.Now + delay)
  • NeverStop: Disables effects from previously called StopAt and StopAfterNumberOfRuns.
  • label: Optional text label for your task.
  • cluster: cluster name ex: "high-mem" or "dedicated".


PM> Install-Package Iron.IronCache

// =========================================================
// Cache
// =========================================================

IronCacheRestClient ironCacheClient = IronSharp.IronCache.Client.New();

// Get a Cache object
CacheClient cache = ironCacheClient.Cache("my_cache");

// Put value to cache by key
cache.Put("number_item", 42);

// Get value from cache by key

// Get value from cache by key

// Numbers can be incremented
cache.Increment("number_item", 10);

// Immediately delete an item

cache.Put("complex_item", new {greeting = "Hello", target = "world"});

// Get value from cache by key

Something went wrong with that request. Please try again.